python 字典 感觉就是object 对象
字典的简单用法
# 字典 # - 最简单的字典 mydict = { 'nickname':'大力水手', 'age': 18, 'points': 80 } print(mydict) print(mydict['nickname']) print(mydict['points']) # - 修改字典的值 mydict['points'] = 98 print(mydict['points']) # - 删除字典的键值对 del mydict['age'] print(mydict) # - 遍历字典 for key,val in mydict.items(): print('\nKey:' + str(key) + '-Val:' + str(val)) # - 遍历字典的所有键 for item in mydict.keys(): print('\nKey:'+ str(item)) # - 遍历字典的所有值 for item in mydict.values(): print('\nValue:'+ str(item))