python 定义二维数组

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 >>>
上一篇:tomcat的配置文件server.conf中的元素的理解


下一篇:如何用tomcat实现类似weblogic那样的热部署方式