python创建n行m列数组示例

leemboy 2019-12-02

我就废话不多说了,直接上代码吧!

>>> matrix=[None]*2
>>> print(matrix)
[None, None]
>>> for i in range(len(matrix)):
 matrix[i ]=[0]*3
>>> print(matrix)
[[0, 0, 0], [0, 0, 0]]
>>>

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

相关推荐