1. 程式人生 > >python建立陣列

python建立陣列

第二種:
n = 2
m = 3
matrix = [None]*2
for i in range(len(matrix)):
    matrix[i] = [0]*3
print(matrix)

第一種:
n = 2
m = 3
matrix = [[0]*m for i in range(n)]
print(matrix)
matrix[0][0] = 1
print(matrix)