python中有個縮略的寫法,如下
a = a +1 等同於 a +=1
發現了一個有趣之處,+=的寫法中間不能有空格,否則報錯,測試如下
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> a=1
>>> a +=1
>>> a 2
>>> a+ = 1 SyntaxError: invalid syntax >>>