标签:values 覆盖 注意 pre none one 循环 bsp 存在
2018-12-27
(1212,"asnfuih",[2131,"safg"],)
info = {
"k1" : "v1", #键值对 key : value
"k2" : "v2"
}
value可为任何值,可无限嵌套
列表、字典不能作为字典的key,注意布尔值和1,0的重复,key出现重复时只显示一个
字典是无序的
del dict[key]
v = dict.fromkeys(["wcb","lyn",123],21) print(v) v1 = dict.fromkeys(("wcb","lyn",123,),21) print(v1) v2 = dict.fromkeys({"wcb","lyn",123},21) print(v2) 结果为: {‘wcb‘: 21, ‘lyn‘: 21, 123: 21} {‘wcb‘: 21, ‘lyn‘: 21, 123: 21} {‘wcb‘: 21, 123: 21, ‘lyn‘: 21} #此处还体现了字典的无序性
dic = {"k1":"v1"} v = dic.get("k1") print(v) v1 = dic.get("k1111") print(v1) v2 = dic.get("k1111","test") print(v2) 结果为: v1 None test
2018-12-27 20:36:51
标签:values 覆盖 注意 pre none one 循环 bsp 存在
原文地址:https://www.cnblogs.com/LynWcb596922/p/10187181.html