somepeople

python赋值运算符

1.增量赋值

+=、-=、*=、%=、**=等等

2.链式赋值

a =1

b =a

c =b

3.交替赋值

m = 10

n = 20

m,n = n,m

m = 20

n =10

4.解压赋值

a,b,c = [1,2,3]
print(a,b,c)
#1 2 3
a,b,c,*_ = [1,2,3,4,5,6,7]
print(a,b,c,_)
#1 2 3 [4, 5, 6, 7]

 

posted on 2021-01-16 23:54  Hello_Thanos  阅读(319)  评论(0编辑  收藏  举报

导航