Python二维列表数组list的初始化与赋值

参考代码

List=[]
Length=8
for i in range(Length):
    List.append([])#初始化二维列表
List[0].append(1)
List[0].append(2)
List[0].append(3)
List[7].append(50)
print(List)

运行结果

[[1, 2, 3], [], [], [], [], [], [], [50]]

猜你喜欢

转载自blog.csdn.net/qq_43511299/article/details/113776955