python修改文件内容
2014-02-28 23:01
561 查看
def func(filename): input = open(filename) lines = input.readlines() input.close() output = open(filename,'w') for line in lines: if not line: break if (('appdef.h' in line) and ('include' in line) ): temp = line.split("appdef") temp1 = temp[0] + 'datatype'
+ temp[1] output.write(temp1) else: output.write(line) output.close()
+ temp[1] output.write(temp1) else: output.write(line) output.close()
相关文章推荐
- Python 快速入门
- Dijkstra 调度场算法 Python实现 一
- Python3.3 input v.s. raw_input
- Python小程序:获取二进制文件的所有内容
- Python内存泄漏问题查找
- wxPython
- Python小程序:获取文本文件的所有内容
- python使用Tkinter编写GUI
- 深入学习python (五) 当pip install 失败抛锚时该怎么办
- python2.7 +xp+setuptool
- python编写GUI
- Python 之模块fnmatch
- python-django中的request对象,得到其POST或GET的JSON数据
- Python正则表达式指南
- python延迟指定时间执行特定任务脚本
- python3.x IDLE学习及基础语法(学习head first python 第一章)
- Python *与** 参数问题
- python 类的使用
- 关于python 安装 delicious
- python 科学计算学习一:numpy文件存取,内存映射