python 字典的系列操作

d={'name':'chain','age':19,'gender':'female'}#创建字典 按照 键:值 的格式创建

d['name']#按照键来取值

d['age']+=1 #给年龄加1

d={'boss':{'fristname':'xiong','age':54},'manger':{'fristname':'gao','age':32},'manger02':{'fristname':'lei','age':26}}#字典的嵌套

d['boss']['age']#取出boss的年龄

d.keys()#keys函数取出所有的键

猜你喜欢

转载自www.cnblogs.com/thechain/p/9258487.html