1. myList = [([0] * n) for i in range(m)],n是列,m是行
>>> array=[([0]*3) for i in range(4)]
>>> for i in range(4):
... for j in range(3):
... print array[i][j],
... print "\n"
...
0 0 0
0 0 0
0 0 0
0 0 0
>>> array[0][1]=1
>>> for i in range(4):
... for j in range(3):
... print array[i][j],
... print "\n"
...
0 1 0
0 0 0
0 0 0
0 0 0
>>>
2.array = [ [ 0 for i in range(n)] for i in range(m)],n是列,m是行
>>> array=[[0 for i in range(3)] for i in range(4)]
>>> for i in range(4):
... for j in range(3):
... print array[i][j],
... print "\n"
...
0 0 0
0 0 0
0 0 0
0 0 0
>>> array[0][1]=1
>>> for i in range(4):
... for j in range(3):
... print array[i][j],
... print "\n"
...
0 1 0
0 0 0
0 0 0
0 0 0
>>>