1. 程式人生 > >python 小知識

python 小知識

小知識 python += nbsp num style pos 輸出結果 spa

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]

python 小知識