Python_Python遍历列表的四种方法
来源:互联网 发布:iphone6s虚拟定位软件 编辑:程序博客网 时间:2024/05/17 22:42
方式一:
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
2 0
- Python_Python遍历列表的四种方法
- Python_Python遍历列表的四种方法
- Python_Python建立SSH连接的方法
- Python_Python plugin 列表
- python_python中try except处理程序异常的三种常用方法
- 遍历集合、数组的四种方法
- java Map 遍历的四种方法
- 遍历HashMap的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- java 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 遍历Map的四种方法
- 通过文件的md5码比对两个文件是否一样
- 利用host文件上谷歌google【Windows】【Mac】
- nginx 安装部署 步骤 及配置解读
- FPGA视频拼接器的DP 的4k 功能输入, 把lvds 转为 serdes
- Zookeeper实现集群和负载均衡---(4)Zabbix集成集群监控
- Python_Python遍历列表的四种方法
- 用Eclipse上传项目到svn服务器
- Composer入门(转)
- Java 正则表达式
- 拼图游戏源码-swift版项目源码
- [Computer Security : Art and Science] Chapter_7 7.4 RBAC (基于角色的访问控制)
- STM32 USB学习笔记5
- Android中Settings.System的使用(系统全局变量)
- Android开发中无处不在的设计模式——单例模式