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)

运行结果:

posted @ 2021-04-19 13:46  肥泽~  阅读(61)  评论(0编辑  收藏  举报