2.8

程序文件ex2_8.py

dict1 ={'Alice': '123', 'Beth': '456', 'Cecil': 'abc'}
print(dict1['Alice']) #输出123
dict1['new'] = 'Hello' #增加新的键值对
dict1['Alice'] = '1234' #修改已有键值对
dict2 = {'abc': 123, 456: 78.9}
print(dict2[456]) #输出78.9

posted @ 2024-10-14 10:17  qi11  阅读(3)  评论(0编辑  收藏  举报