当我将值设置为f [i-1] [j]时,为什么f [i] [j]的值会改变

时间:2017-08-03 04:43:23

标签: python

以下是我的示例代码:

#!/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]的值会改变?

0 个答案:

没有答案