'''字典的值可以是相同的''' scores={'张三':100,'李四':100,'王五':100} print(scores['李四']) print(scores['张三']) '''字典的key不能是相同的''' scores1={'张三':101,'张三':102,'张三':103} print(scores1['张三'])
E:\PycharmProjects\pythonProject\venv\Scripts\python.exe E:/PycharmProjects/pythonProject/demon1/demo7.py 100 100 103 进程已结束,退出代码0
#字典必须是不可变对像,以下代码为错误代码,运行显示报错
lst=[1,2,3] d={lst:100} #字典必须是不可变对像,此代码为错误代码 print(d)
Traceback (most recent call last): File "E:/PycharmProjects/pythonProject/demon1/demo7.py", line 10, in <module> d={lst:100} TypeError: unhashable type: 'list'
标签:pythonProject,张三,特点,lst,print,7.8,100,字典 From: https://www.cnblogs.com/988MQ/p/16643036.html