Python拆包与组包

拆包

拆开、分解

tuple = ("李四", 23, "男")
name, age, sex = tuple
print(name,age,sex)

#输出结果李四 23 男

组包

结合

name = "李四"
age = 23
sex = "男"
my_tuple = (name, age, sex)
print(my_tuple)

#输出结果('李四', 23, '男')


猜你喜欢

转载自blog.csdn.net/weixin_44024993/article/details/107472161
今日推荐