我试图将一些元组插入到2D数组中,但由于某种原因,x值似乎没有增加。
x_axis = 20
y_axis = 4
arr = [[None]*y_axis]*x_axis
for x in range(x_axis):
for y in range(y_axis):
arr[x][y] = (x,9,y,6)
for x in range(x_axis):
for y in range(y_axis):
print arr[x][y]
我得到了这个:
(19, 9, 0, 6)
(19, 9, 1, 6)
(19, 9, 2, 6)
(19, 9, 3, 6)
(19, 9, 0, 6)
(19, 9, 1, 6)
(19, 9, 2, 6)
(19, 9, 3, 6)
(19, 9, 0, 6)
(19, 9, 1, 6)
(19, 9, 2, 6)
(19, 9, 3, 6)
(19, 9, 0, 6)
(19, 9, 1, 6)
(19, 9, 2, 6)
(19, 9, 3, 6)
(19, 9, 0, 6)
(19, 9, 1, 6)
(19, 9, 2, 6)
(19, 9, 3, 6)
我不知道x
为什么坚持19(范围的最后一个数字)而不仅仅是0-19(包括0-19)。