python 中新建一个二维矩阵的方法
2018-07-12 本文已影响1人
fred_33c7
- 怎么样新建一个二维矩阵
Matrix = [][]
或者Matrix = [5][5]
都是不行的
#Creates a list containing 5 lists, each of 8 items, all set to 0
w, h = 8, 5;
Matrix = [[0 for x in range(w)] for y in range(h)]
Matrix = [][]
或者Matrix = [5][5]
都是不行的#Creates a list containing 5 lists, each of 8 items, all set to 0
w, h = 8, 5;
Matrix = [[0 for x in range(w)] for y in range(h)]