Код: Выделить всё
import numpy as np
arr1 = np.array([1,0,1])
arr2 = np.array([0,0,1])
total1 = np.add(arr1, arr2)
>>> [1 0 2]
total2 = total1 #Purely to make multiple to elaborate my issue
variables = [total1, total2]
for x in variables:
x = x + 100
total1
>>> [1 0 2]
Код: Выделить всё
total1Переменная Код: Выделить всё
for x in variables:
x += 100
total1
>>> [201, 200, 202]
Код: Выделить всё
for x in variables:
x = x / 1 * 100 #I have simplified the maths for ease of reading
#This is my desired output - note how total1 is updated, not created
total1
>>> [100, 0, 200]
Подробнее здесь: https://stackoverflow.com/questions/402 ... umpy-array
Мобильная версия