Python 读取文件 写入文件
来源:互联网 发布:linux shell编程实例 编辑:程序博客网 时间:2024/06/05 02:38
读取文件:
#coding=utf-8try:f=open('aa.txt') #默认以只读的方式打开文件#word=f.read() #一次性读取,文件较大时不适合#word=f.read(20) #一次性读取20个字符line=f.readline()while line!='':print(line)line=f.readline()f.close()except IOError:print("文件打开出错!!")exit()
写入文件:
#coding=utf-8try:f=open('aa.txt','w') #r:只读,w:写(替换),a:附加(不替换),r+:读取和写入(不常用)f.write('This file is not empty!')f.close()except IOError:print("文件打开出错!!")exit()
阅读全文
0 0
- python读取写入文件
- Python读取写入文件
- Python 读取文件 写入文件
- python(文件读取写入)
- python 写入、读取txt文件
- Python:读取文件并分词+文件写入
- Python读取excel写入到RTF文件
- 使用Python读取和写入CSV文件
- python使用xlwt读取文件写入Excel
- Python 文件读取与写入操作方法
- 使用Python读取和写入CSV文件
- Python读取和写入Excel文件[整]
- 关于python文件的读取创建写入
- 用python读取、写入txt文件
- python读取并写入mat文件
- Python 读取写入 json 格式的文件
- python读取并写入mat文件
- python读取cvs文件并写入mongodb
- jquery UI API-滑块部分(Slider widget)
- Android 屏幕适配方案
- jquery-parent(),parents()与closest()的区别
- 【转载】Google Hacking
- linux 使用sh启动多jar包 编写三个脚本
- Python 读取文件 写入文件
- 二级列表ExpenableList
- 指针
- Linux环境下查看历史操作命令及清除方法
- repe cmpsb指令解析
- spring添加事务控制
- Unicode数据类型(个人笔记)
- Handler倒计时
- 2017年9月反思