python 赋值魔法
序列解包:
>>> x,y,z = 1, 2, 3
>>> print(x, y, z)
1 2 3
>>> a,b, *reset = [1,2,3,4]
>>> print(a,b,reset)
1 2 [3, 4]
链式赋值:
x = y = function
增量赋值:
>>> x = 2
>>> x +=1
>>> x
3
>>> x *=2
>>> x
6
>>> fnord = 'foo'
>>> fnord +='bar'
>>> fnord
'foobar'
>>> fnord *=2
>>> fnord
'foobarfoobar'