<p>我使用一个循环来创建元组,我想把这些元组插入一个大元组。你知道吗</p>
<p>假设我的输入是(1,2,3),这是从每个循环生成的,我的预期输出是((1,2,3),(1,2,3))。你知道吗</p>
<p>我试过多种方法,但还是不知道怎么做。你知道吗</p>
<pre><code>big_tup = ()
for i in range(2):
tup = (1, 2, 3)
# this will cause AttributeError: 'tuple' object has no attribute 'insert'
big_tup.insert(tup)
# this will combine all tuples together, output: (1, 2, 3, 1, 2, 3)
big_tup += tup
# this will make duplicates of (), output: (((), 1, 2, 3), 1, 2, 3)
big_tup = (big_tup,) + tup
</code></pre>
<p>如果有人能帮我解决这个问题,我将不胜感激。提前谢谢!你知道吗</p>