增强型赋值运算符

python中用“=”表示赋值,如:

a = 100

还可以用运算符与赋值符结合构成增强型赋值运算符(中间不能加空格),如:

# 增强型赋值运算符
a += 1
# 相当于 a = a + 1

类似还有:-=, *=, /=, //=,**=, %=

猜你喜欢

转载自www.cnblogs.com/doc-wang/p/11839450.html