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))
原文地址:https://www.cnblogs.com/karl-python/p/14498487.html