Python Exercise #20
2013-06-02 17:19
651 查看
#!/usr/bin/python # exact position of python #!/usr/bin/env python # position of python in enviornment # -*- coding:utf-8 -*- # coding # Purpose: Functions And Files from sys import argv script, input_file = argv def print_all(f): print f.read() def rewind(f): f.seek(0) def print_a_line(line_count, f): print line_count, f.readline() current_file = open(input_file) print "First let's print the whole file:\n" print_all(current_file) print "Now let's rewind, kind of like a tape." rewind(current_file) print "Let's print three line:" current_line = 1 print_a_line(current_line, current_file) current_line += 1 print_a_line(current_line, current_file) current_line += 1 print_a_line(current_line, current_file)
相关文章推荐
- Python实现Pat 1035. Password (20)
- 【16-20】LeetCode:Python解题
- Python 练习实例20
- fedora20 下 django1.6+python3 使用mysql
- Python Exercise #25
- 【20】Python100例基础练习(4)
- python爬虫v.20
- 1049. 数列的片段和(20)——Python
- Hard way to learn python 笔记19-20
- python浓缩(20)
- python练习集100题(1-20)
- 1079. 延迟的回文数 (20)——Python
- Python 学习入门(20)—— 循环
- python: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 20: ordinal not in rang
- Python 语言及其应用 Chapter_4_Exercise
- python总结20 高级查询、事务、视图
- PythonStock(20)股票系统:使用docker hub 上传镜像
- 20、Selenium + Python 实现 UI 自动化测试-AutoIT工具
- Python(20)python中的文件(open)
- Python 语言及其应用 Chapter_10 Exercise