1. 序列解包 sequence unpacking
ex1
x,y,z = 1,2,3
x,y=y,x
print x,y,z
2 1 3
ex2
d={'name':'stewart','age':'25' }
print d
key,value = d.popitem() #popitem()随机取出一项键值对
print key,value
{'age': '25', 'name': 'stewart'}
age 25
2.链式赋值 chained assignment
x,y=1,2
u=y=x #等同于y=x,u=y
print x,y,u
1 1 1
3.增量赋值 augmented assignment
x,y=1,'foo'
x +=3
x *=4
y +='bar'
y *=2
print x,y
16 foobarfoobar
转载于:https://blog.51cto.com/bretoncrepe/1586997