数学建模例题2.9 字典的get()方法使用示例

`Dict={'age':18,'score':[98,97],'name':'Zhang','sex':'male'}
print(Dict['age']) #输出18
print(Dict.get('age')) #输出18
print(Dict.get('address','Not Exists.')) #输出No Exists
try:
print(Dict['address'])
except KeyError:
print('Key "address" does not exist in the dictionary.')

print("学号:3005")`

posted on 2024-10-28 11:43  VVV1  阅读(3)  评论(0编辑  收藏  举报