info = {"name": "nfx", "age": 18, "status": True}
print(info["name"], info["age"], info["status"])
print(info.get("name"))
print(info.get("height"))
print(info.get("height","没写身高"))
print(info.get("age", 20))
print(info.keys())
for key in info.keys():
print(key)
print(info.values())
for value in info.values():
print(value)
print(info.items())
for item in info.items():
print(item)
info["score"] = 95
info["age"] = 28
info.update({"age": 30, "height": 180})
info.setdefault("name", "没写姓名")
info.setdefault("weight", "没写体重")
print(info)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37