简单的程式码,用Python 3 Jupyter Notebook
import random
List = [[0] * 3 ]*5
for m in range(0,5):
for n in range(0,2):
List[m][n] = random.randint(0,1)
print(List)
得到
[[0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0]]
欸不是,为什么这样会重复啦
害我只能写很长一条来切...不然分段都会每段重复...