【发布时间】:2021-10-31 17:05:03
【问题描述】:
我的代码如下所示:
firstValue = "First Value Key"
secondValue = "Second Value Key"
thirdValue = "Third Value Key"
Dictionary = {"0":firstValue,
"1":secondValue,
"2":thirdValue}
print(Dictionary["0"])
firstValue = "New Value"
print(Dictionary["0"])
输出如下:
First Value Key
First Value Key
我希望输出看起来像这样:
First Value Key
New Value
我错过了什么?
【问题讨论】:
-
字典包含对 value 的引用,而不是 name。推荐阅读:nedbatchelder.com/text/names.html
标签: python dictionary pointers variables