python创建二维列表
ls = [[] for i in range(7)]
print('ls==', ls)
for k in range(1, 7): # 1-9
test = [i for i in range(k)]
ls[k] = test
print('ls==', ls)
运行结果:
ls = [[] for i in range(7)]
print('ls==', ls)
for k in range(1, 7): # 1-9
test = [i for i in range(k)]
ls[k] = test
print('ls==', ls)
运行结果: