例如很好地發揮:Python中,元組參數與他人
mytuple = ("Hello","World")
def printstuff(one,two,three):
print one,two,three
printstuff(mytuple," How are you")
這自然崩潰了與類型錯誤,因爲我只給了它兩個參數,它需要三個。
有沒有一種簡單的方法來有效地「分裂」一個元組,而不是擴展一切?像:
printstuff(mytuple[0],mytuple[1]," How are you")
爲什麼要分片元組? – ncoghlan 2011-03-29 01:50:08
匹配原始示例中的元素。 – yan 2011-03-29 02:31:34
但是'mytuple'已經是2元組了。所以你沒有明顯的原因切片2元組(有效地複製它)。 – ncoghlan 2011-03-29 03:14:12