我想像这样在 python 语句中解压一个元组:
a = 5, *(6,7)
但这会引发一个SyntaxError
。实现这样的目标最干净的方法是什么?
到目前为止我想到的最好的是:
a = tuple([5]+list((6,7)))
最佳答案
您可以直接连接元组:
>>> a = (5,)+(6, 7)
>>> a
(5, 6, 7)
关于python - 元组在赋值中解包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11021185/