python 小知识

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]

posted @ 2018-03-18 16:27  sneike  阅读(118)  评论(0编辑  收藏  举报