以下是我的示例代码:
#!/usr/bin/python
import sys
m=1
n=1
f = [[0]*(m+1)]*(n+1)
for i in range (1, n+1):
for j in range (0, m+1):
f[i][j] = 101
print "check 1: " + str(f[i][j])
f[i-1][j] = 102
print "check 2: " + str(f[i][j])
print"\n"
我得到的输出:
check 1: 101
check 2: 102
check 1: 101
check 2: 102
当我改变f [i-1] [j]时,为什么f [i] [j]的值会改变?