【发布时间】:2018-10-23 05:28:17
【问题描述】:
我有一个这样的python代码:
experiment_str = ['0', '1', '2', '3', '4', '5']
conversation_dict = dict.fromkeys(experiment_str,[])
conversation_dict['0'].append(10)
我只想将10 添加到第一个键,但它会添加到所有键。你能帮我理解一下吗?
【问题讨论】:
-
它有效。非常感谢!
标签: python list dictionary