python 字典
字典
band=['1', '2', '3', '4']
slogan=['one','two','three','fourth']
dict1={'1':'one', '2':'two', '3':'three', '4':'fourth'}
dict1[2]
dict2={} //创建字典
dict() //创建字典
dict3=dict((('F',70),('i',105),('s',115)))
dict4=dict(fish='let you eat',flower='let you love')
dict1={}
dict1.fromkey((1,2,3))
dict1.fromkey((1,2,3),('one','two','three')
dict1=dict1.fromkeys(range(32),'赞')
dict1.get(32,'木有!')
dict1.clear() //清空
dict1={} // 不推荐 可能会通过其他的访问到信息
dir(dict)
a={1:'one',2:'two',3:'three'}
b=a.copy()
c=a
id(a)
id(b) //不同
id(c) //贴了一个标签在同一个字典上
a.pop(2)
a.popitem()
a.setdefault('小白','dog')
版权声明:本文为weixin_37619409原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。