python第28篇--异常
来源:互联网 发布:it项目经理岗位职责 编辑:程序博客网 时间:2024/06/15 02:16
#!/usr/bin/pythonimport timetry: f = open('poem.txt') while True: line = f.readline() if len(line) == 0: break print(line,end=' ') time.sleep(2)except KeyboardInterrupt: print('!!You cancelled the reading from the file')finally: f.close() print('(cleaning up:closed the file)')
结果:
ang@ubuntu:a_byte_python->./7finally.py programming is fun when the work is done if you wanna make your work also fun: usr python! (cleaning up:closed the file)ang@ubuntu:a_byte_python->./7finally.py programming is fun when the work is done^C !!You cancelled the reading from the file(cleaning up:closed the file)
到这里基本上python的语法就大部分完成了,剩下的就是多使用,体验其美妙之处,以及熟悉库的使用。
阅读全文
0 0
- python第28篇--异常
- python第27篇之--异常
- python第15天:异常
- python 第8章 异常处理
- Python基础教程之第8章 异常
- 【Python基础教程】第8章 异常
- Python语法第8讲:异常处理
- 第8章 Python笔记 异常
- 《Python核心编程》第10章 错误和异常 练习
- <<Python基础教程>>学习笔记 | 第08章 | 异常
- python基础教程共60课-第36课异常处理
- 第19节--python常见错误与异常处理
- Python编程入门-第9章 异常处理 -学习笔记
- Python编程入门-第10章 异常处理 -学习笔记
- Python核心编程---读书笔记:第10章 错误和异常
- Python--小甲鱼学习笔记--第32课:异常处理
- 基础卷_异常篇 第10集 异常--总结
- 基础卷_异常篇 第12集 异常练习
- Flask Web开发 表单
- 修改、编译IDA 6.8 插件 Class Informer 2.4
- python第27篇之--异常
- About of jcl
- TCP/IP协议栈源码冰山一角图
- python第28篇--异常
- Ruby语言基础
- Git之路——配置SSH免密码登录
- LINUX 命令详解
- . Ubuntu15.04设置自动锁屏时间
- 贪心之小船过河问题
- numpy.bincount使用
- 阿里云 centOS7下安装MySQL教程
- XmlPullParser 解析XMl文件