【发布时间】:2014-07-28 01:19:27
【问题描述】:
这是我将列表值附加到字典中的程序
lis=['a','b','c']
st=['d','e']
count=0
f={}
for s in st:
lis.append(s)
f[count]=lis
count+=1
print f
我的预期输出是
{0: ['a', 'b', 'c', 'd'], 1: ['a', 'b', 'c', 'd', 'e']}
但我明白了
{0: ['a', 'b', 'c', 'd', 'e'], 1: ['a', 'b', 'c', 'd', 'e']}
作为输出。请帮我解决这个问题。提前致谢。
【问题讨论】:
-
是否有任何模式.. 得到结果
-
没有。我需要这样的输出 {0: ['a', 'b', 'c', 'd', 'e'], 1: ['a', 'b', 'c', 'd', ' e']}
-
a中的f[count]=a是什么? -
f[count] = lis + [s]
标签: python