ซ่อมคอมพิวเตอร์นอกสถานที่ บางกะปิ
www.becomz.com

วันเสาร์ที่ 22 ธันวาคม พ.ศ. 2555

Python : Dict

# Dict (mutable): "key:val"
# key (immutable): int, float, bool, str, tuple
dict1 = { 'id':10, 'age':20, 11:'hello', 0.5:30.5, ('hello',3):[10,20] }
print(type(dict1), len(dict1), dict1)
print( dict1[11], dict1['id'], dict1[('hello',3)] )

dict1['id'] = 12345
print(dict1)

return_val = dict1.pop('age')
print(dict1)

dict1['gender'] = 'F'
print(dict1)
Share:

0 ความคิดเห็น:

แสดงความคิดเห็น

Disqus Shortname

Comments system

ขับเคลื่อนโดย Blogger.

จำนวนการดูหน้าเว็บรวม

Blog Archive

Post Top Ad

คลังบทความของบล็อก

Author Details

Menu - Pages

Business

Random Posts

Recent

Popular

Blog Archive