Python:在元组中解包元组
可以在新的元组中解包元组吗 大概是这样的:Python:在元组中解包元组,python,python-2.7,tuples,unpack,Python,Python 2.7,Tuples,Unpack,可以在新的元组中解包元组吗 大概是这样的: x = (1, 2) y = (*x, 3) # This is not allowed # print y should then give (1, 2, 3) 在Python3.5中是允许的。你在用Python 2吗?啊,是的,我的错。我用的是2.7.6。很高兴知道@KevinGuanWhy不y=x+(3,)。Akavail的示例也适用于python2.7和upLol。放屁。谢谢@Akavall,虽然这在python 3中是允许的,但很有趣。显然
x = (1, 2)
y = (*x, 3) # This is not allowed
# print y should then give (1, 2, 3)
在Python3.5中是允许的。你在用Python 2吗?啊,是的,我的错。我用的是2.7.6。很高兴知道@KevinGuanWhy不
y=x+(3,)
。Akavail的示例也适用于python2.7和upLol。放屁。谢谢@Akavall,虽然这在python 3中是允许的,但很有趣。显然有人觉得它很有用。