Python for循环之查找下一个记录
来源:互联网 发布:淘宝有毛片吗 编辑:程序博客网 时间:2024/06/11 04:22
我们在使用for循环的时候,由于python语言的高效性,致使我们渐渐忽略了一个很重要的角色,index。
怎样查找当前记录的下一条记录呢?
li1 = [3, 4, 5, 6, 7] i = 0 for rec in li1: print "this record is: " + str(rec) if i + 1 < len(li1): print "next record is: " + str(li1[i + 1] else: print "the last record!" print '\n' i += 1运行结果:
this record is: 3next record is: 4this record is: 4next record is: 5this record is: 5next record is: 6this record is: 6next record is: 7this record is: 7the last record!
阅读全文
1 0
- Python for循环之查找下一个记录
- Python之for循环
- python之for循环详解
- Python探索之路(四)---for循环嵌套for循环
- python学习笔记之-for循环
- Python探索之路(三)---for循环
- Python之if,for和while循环
- Python基础篇之for循环
- Python的for循环
- python for 循环
- Python for循环
- python中的for循环
- python迭代器 for循环
- Python for 循环语句
- python中的for循环
- python中的for循环
- Python--for循环
- python-for循环
- 解决方法 [ubuntu phpmyadmin 错误提示: 缺少 mcrypt 扩展,请检查 php 配置]
- Safe Or Unsafe(哈夫曼树)
- jQuery关于对表单进行验证和验证码的实现
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- WEB前端开发人员须知的常见浏览器兼容问题及解决技巧
- Python for循环之查找下一个记录
- Android xUtils3源码解析之数据库模块
- Eclipse如何正确的从svn中检出maven项目
- 【原创】Spring-boot快速入门(一)HelloWord!--转载请注明出处
- 0-1背包问题(动态规划)
- Copy Elision
- 计算文件大小
- grunt代码混淆
- Linux下使用yum安装MariaDB