- + = Compared with the integer type or the string type, the arithmetic characters are added first and then assigned (modified reference)
- In Python, calling a list variable to variable += is basically an extension method to move the list and it won’t change the variable’s reference
def demo(num, num_list):
Print («внутренний код функции»)
# num = num + num
num += num
# num_list.extend (num_list). Поскольку это метод вызова, он не будет изменять ссылку на переменную
# После выполнения функции внешние данные также изменятся
num_list += num_list
print(num)
print(num_list)
Print («внутренний код функции»)
gl_num = 9
gl_list = [1, 2, 3]
demo(gl_num, gl_list)
print(gl_num)
print(gl_list)