Python文件操作2
来源:互联网 发布:淘宝美工做什么工作的 编辑:程序博客网 时间:2024/06/16 13:34
文件操作:
r 读
r+ 读写
w 写入 重新创建
w+ 读写入 重新创建
a 写入 追加 创建
a+ 读写 追加 创建
b 以二进制打开文件
U 支持所有换行符
f = file('hello.txt',"a+")f.writelines('chejia\n')f.writelines('123456\n')f.flush()f.seek(0)print f.encodingprint f.modeprint f.tell()print f.readline()f.seek(0)print f.readlines()f.close()#文件的赋值src = file('hello.txt','r')dst = file('hello word.txt','w')dst.write(src.read())dst.close()src.close()#文件的删除import os.pathif os.path.exists('hello.txt'): os.remove('hello.txt') print 'del'输出:a+0chejia['chejia\n', '123456\n']del
0 0
- python-文件操作(2)
- Python文件操作2
- Python学习2:文件操作
- Python文件的操作2
- 2---Python:简单文件操作
- Python 文件操作常用操作
- [python]python操作xml文件
- Python文件操作
- python文件目录操作
- Python文件操作
- Python文件操作
- python 文件操作
- python 文件操作
- Python 文件操作
- python 文件操作
- Python文件操作
- python 文件读写操作
- Python文件读写操作
- hdu 4034 预处理+map映射字符串
- linux的php环境安装php+mysql+nginx
- 单例模式
- OC-视图
- Toast中的setDurition使用不起作用的原因
- Python文件操作2
- ccf201604-3路径解析
- 一个会转的图案(绕右侧中点/绕一侧)
- css3-多列布局
- 第四章 Generics - 泛型
- 《Java源码分析》:PriorityQueue
- Android自定义View之可随时暂停、开启的圆形下载进度条
- web项目实战实现焦点图轮播
- gpiolib及gpio操作