0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

辞書について(Ruby学習後のPython初学)

Posted at

#ディクショナリ(辞書)
####辞書とはまとまったデータをテキスト(キー)で扱うもの
#####主に辞書はDBとのやりとりをキーを用いてデータ処理をする時などに便利となる

qiita.py
dic = {"single":1, "double":"two"}
#リストと違って波括弧を用いる

len(dic) #辞書の中身の数
print(len(dic)) #この場合は2

#データ追加する場合
dic["triple"] = "three"

#変更する場合
dic["triple"] = 3

#削除する場合
del dic["triple"] #"triple":3がdicから削除される

キーには変数も代用できるが、存在していないキーであればエラーとなる

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?