求助,一个列表的问题
name_list= ['A', 'B', 'C','D']
data = [
[
['A','B','C'],
[20,40,10],
[120,140,600]
],
[
['A','C','D'],
[1,2,3],
[10,20,30]
]
]
n = 0
ls = []
while n <len(name_list):
ls.append(0)
n +=1
list = []
n = 0
while n < len(data):
kongf = []
m = 0
while m<len(data[n]):
kongf.append(ls)
m +=1
list.append(kongf)
n +=1
for i in list:
n = 0
while n<len(i):
i[0]=name_list
n +=1
print(list)
#list= [[['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]], [['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]]]
n = 0
while n <len(data):
m = 0
while m <len(data[n]):
k = 0
while k<len(data[n][m]):
list[n][m][list[n][0].index(data[n][0][k])]=data[n][m][k]
k +=1
m +=1
n +=1
for i in list:
print(i)
'''
这是注释掉第45 行# “list= ”的结果
[[['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]], [['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]]]
[['A', 'B', 'C', 'D'], [10, 140, 20, 30], [10, 140, 20, 30]]
[['A', 'B', 'C', 'D'], [10, 140, 20, 30], [10, 140, 20, 30]]
'''
'''
这是 没有 注释掉第45 行# “list= ”的结果,这种结果是我想要的!!!!!!!!!!!!!!!!!
[[['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]], [['A', 'B', 'C', 'D'], [0, 0, 0, 0], [0, 0, 0, 0]]]
[['A', 'B', 'C', 'D'], [20, 40, 10, 0], [120, 140, 600, 0]]
[['A', 'B', 'C', 'D'], [1, 0, 2, 3], [10, 0, 20, 30]]
'''
请问这是怎么回事?谢谢大家