python中同时给多个变量赋值
python中可以同时给多个变量赋值,下面列举了三种方法
直接赋值
a, b = 0, 1 assert a == 0 assert b == 1 ··· 从列表赋值 ```python (r,g,b) = ["Red","Green","Blue"] assert r == "Red" assert g == "Green" assert b == "Blue"
从元组赋值
(x,y) = (1,2) assert x == 1 assert y == 2
相关文章