Python 给多个变量同时赋值

#给多个变量赋值
data=[‘alex’,84,[1900,3,38]]
name,age,birth=data
print(name)
print(age)
print(birth)

msg=‘hello’
a,b,c,d,e=msg
print(a,b,c,d,e)

msg=‘hello’
a,,,,b=msg
print(a)
print(b)
#只给第一个和最后一个变量赋值
a,*
,b=msg
print(a,b)

猜你喜欢

转载自blog.csdn.net/oTianShiZaiChangGe1/article/details/88627903