Python遍历列表的四种方法
2018-03-28 11:03
671 查看
方式一:
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 列表(List) 的三种遍历(序号和值)方法
- Python 列表(List) 的三种遍历方法实例 详解
- Python遍历列表的四种方式
- python 字典(dict)遍历的四种方法性能测试报告
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历列表的四种方式
- Python遍历字典的四种方法对比
- Python遍历列表的四种方式
- python通过索引遍历列表的方法
- Python遍历列表的四种方式
- Python递归遍历列表及输出的实现方法
- python 字典(dict)遍历四种方法的性能
- Python遍历列表的四种方式
- python遍历删除列表的方法
- Python遍历列表的四种方式
- python 字典(dict)遍历四种方法的性能
- Python遍历字典的四种方法对比