python读取大文件并逐行写入另外一个文件
2016-05-09 09:25
771 查看
<pre name="code" class="python">creazy.txt文件有4G,逐行读取其内容并写入monday.txt文件里。
def creazyRead(): ''' with open("e:creazy.txt","r") as cr: for line in cr: print line ''' ms = open("e:creazy.txt") for line in ms: with open("e:monday.txt","a") as mon: mon.write(line)
另一种方法使用readlines实现:
def creazyRead(): ms = open("e:creazy.txt") for line in ms.readlines(): with open("e:monday.txt","a") as mon: mon.write(line)
相关文章推荐
- wxPython-创建一个最小的空的wxPython程序
- python+scapy 抓包与解析
- ubuntu安装python3.5
- PyCharm使用技巧归纳
- Python中new方法的应用
- python基础
- AWS 命令行界面 + Python 的 AWS 开发工具包 (Boto3)
- 利用pyqt4写Python的图形化界面的笔记
- python学习——python中的文件处理之open()、file()函数
- python学习——python os.path模块常用方法详解
- python学习——函数strip() 与 split()
- mac 安装python-magic
- Python中的yield
- Python脚本备份数据库
- python浓缩(20)
- python浓缩(21)
- QColor中的预定义颜色
- python常用模块
- 利用python爬取58同城简历数据
- python模块