python 将元组解析为多个参数

 

#create a tuple
tuplex = 4, 8, 3
print(tuplex)
n1, n2, n3 = tuplex
#unpack a tuple in variables
print(n1 + n2 + n3)
#the number of variables must be equal to the number of items of the tuple
n1, n2, n3, n4 = tuplex

 

posted @ 2018-11-12 22:25  anobscureretreat  阅读(541)  评论(0编辑  收藏  举报