创建:
#列表的创建
#第一种,通过{},第二种,通过zip,第三种,通过fromkeys
a = {"name":"黄轩","age":"23","sex":"男","score":"优秀"}
b = dict([("name","黄轩"),("age","23"),("sex","男"),("score","优秀")])
c = dict(name="黄轩",age="23",sex="男",score="优秀")
print(a)
print(b)
print(c)
d = ["name","age","sex","score"]
e = ["黄轩","23","男","优秀"]
f = dict(zip(d,e))
f
g = dict.fromkeys(["name","age","sex","score"])
g
增
#增
g["喜欢的人"] = "耿鑫"
g
删
#删除
del g["喜欢的人"]
g
g.popitem()
g.pop("name")
g
改
#改
h = {'name': None, 'age': None, 'sex': None, 'score': None, '喜欢的人': '耿鑫'}
g.update(h)
g
查
#查
g["name"]
g.values()
g.keys()
len(g)