i=0
p=0
intervals_list=[]
zero_list=[]
nonZero_list=[]
nonZero_small=[]
nonZero_big=[]
...
while p<len(intervals_list):
while p in nonZero_list:
nonZero_small.append(intervals_list[nonZero_list[nonZero_list.index(p)]])
p+=1
if p not in nonZero_list:
if p-1 in nonZero_list:
print(nonZero_small)
nonZero_big.append([nonZero_small])
p+=1
del nonZero_small[0:]
print(nonZero_big)**
nonZero_small
)附加到外部列表(nonZero_big
)。
当我打印出nonZero_small
(在第16行)时,效果很好。
我试图将nonZero_small
附加到nonZero_big
(我想附加nonZero_small
的另一个列表)中。 (在第18行中)
但是当我尝试打印nonZero_big
时,它的工作原理是这样的。
[[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[
]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[
]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[
]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], ....... , [[]], [[]], [[]], [[]], [[]],
[[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]], [[]]]
实际上,列表的长度是正确的。但是为什么里面的值没有附加呢?我需要你的帮助。谢谢。