numpy变量是否彼此链接?(帮助)

时间:2018-11-03 12:12:28

标签: python numpy

我写了一个这样的文件:

try 
add app.scss
.alertCustomCss {
        color: #e37b26; // text color for basic alerts
        button {
            color: white !important;
            background-color: color($colors, primary, base) !important;
        }
        .alert-message {
            color: #e37b26; // text color for confirm alerts
            // background-color: color($colors, primary, base) !important;
        }
        .alert-sub-title {
          color: #e37b26; // text color for confirm alerts
        //   background-color: color($colors, primary, base) !important;
        }
        .alert-wrapper {
            background-color: color($colors, gray, base);
        }
        .alert-input {
            color: black;
        }
      }

预期结果是:

import numpy as np
rx = np.zeros((2,2))
rx2 = rx
rx2[0][1]=1
print(rx)
print(rx2)

但是当我运行这段代码时,我得到了:

[[0. 0.]
 [0. 0.]]
[[0. 1.]
 [0. 0.]]

为什么以及如何?

1 个答案:

答案 0 :(得分:1)

import numpy as np
rx = np.zeros((2,2))
rx2 = rx.copy()
rx2[0][1]=1
print(rx)
print(rx2)

结果

[[0. 0.]
 [0. 0.]]
[[0. 1.]
 [0. 0.]]