2.9

Dict = {'age': 18, 'score': [98, 97], 'name': 'zhang', 'sex': 'male'}
try:
print(Dict['age'])
print(Dict.get('age'))
print(Dict.get('address', 'Not Exists.'))
print(Dict['address'])
except KeyError:
print("健'address'在字典Dict中不存在")

posted @ 2024-10-27 23:08  世梦  阅读(48)  评论(0)    收藏  举报