在Python中,可以使用for循環來遍歷元組,并輸出其中的元素。下面是一個示例:
tuple1 = (1, 2, 3, 4, 5) for item in tuple1: print(item)
輸出結果為:
1 2 3 4 5
在這個例子中,我們定義了一個元組 tuple1,然后使用for循環遍歷該元組,并使用print函數輸出每個元素。
tuple1