python 给多个变量赋值

# assign values directly
a = b = 'hello'
a, b = 1, 2
print(b, type(b))
assert a == 1 and b == 2


# assign values from a list
tt2 = [r, g, b] = ["Red", "Green", "Blue"]
print(tt2, type(tt2))


# assign values from a tuple
t3 = (x, y) = (3, 4)
print(x, type(x))
print(t3, type(t3))

 

posted on 2021-03-08 10:53  Karlkiller  阅读(268)  评论(0编辑  收藏  举报

导航