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)

运行结果:

原文地址:https://www.cnblogs.com/Acapplella/p/14676469.html