當前位置:成語大全網 - 新華字典 - python的遍歷循環中的遍歷結構可以是哪些數據結構

python的遍歷循環中的遍歷結構可以是哪些數據結構

列表、元組、字符串等。

1、列表(List):pythonmy_list=[1,2,3,4,5]foriteminmy_list:print(item)

2、元組(Tuple):pythonmy_tuple=(1,2,3,4,5)foriteminmy_tuple:print(item)

3、字符串(String):pythonmy_string="Hello,World!"forcharinmy_string:print(char)