num + = num 不等于num = num + num
例如:
a = [100] def sum(num): # num += num num = num + num # 不等于num += num print(num) sum(a) print(a)
输出结果:[100,100]
[100]
a = [100] def sum(num): num += num print(num) sum(a) print(a)
输出结果:[100,100]
[100,100]
num + = num 不等于num = num + num
例如:
a = [100] def sum(num): # num += num num = num + num # 不等于num += num print(num) sum(a) print(a)
输出结果:[100,100]
[100]
a = [100] def sum(num): num += num print(num) sum(a) print(a)
输出结果:[100,100]
[100,100]