用于在外循环的每次迭代中创建新列表的 mcve,然后附加到内循环中的该列表。
x = []
for n in range(4):
q = []
x.append(q)
#other stuff
for t in range(10):
#other stuff
q.append(t)
>>> from pprint import pprint
>>> pprint(x)
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]
>>>