Python遍历列表的四种方式
2018-01-18 11:10
435 查看
方式一:
输出:
1234
5677
8899
方式二:
输出:
0 1234
1 5677
2 8899
方式三: 使用range()或xrange()
输出:
0 1234
1 5677
2 8899
方式四: 使用iter()
输出:
1234
5677
8899
app_list = [1234, 5677, 8899] <!-- lang: python --> for app_id in app_list: <!-- lang: python --> print app_id
输出:
1234
5677
8899
方式二:
app_list = [1234, 5677, 8899] <!-- lang: python --> for index,app_id in enumerate(app_list): <!-- lang: python --> print index, app_id
输出:
0 1234
1 5677
2 8899
方式三: 使用range()或xrange()
app_list = [1234, 5677, 8899] <!-- lang: python --> for i in range(len(app_list)): <!-- lang: python --> print i,app_list[i]
输出:
0 1234
1 5677
2 8899
方式四: 使用iter()
app_list = [1234, 5677, 8899] <!-- lang: python --> for app_id in iter(app_list): <!-- lang: python --> print app_id
输出:
1234
5677
8899
相关文章推荐
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- python列表和字符串的三种逆序遍历方式
- Python_Python遍历列表的四种方法
- Python遍历列表的四种方法
- python 遍历list四种方式
- 二叉树的四种遍历方式 (前序,中序,后序,层序遍历 python实现)
- Python_Python遍历列表的四种方法
- python列表和字符串的三种逆序遍历方式
- python 列表遍历方式(含下标)
- java集合四种遍历方式