Python读写文件
来源:互联网 发布:淘宝店铺动态 编辑:程序博客网 时间:2024/04/28 22:34
读写文件常用方法
close-关闭文件。相当于保存文件
read-读取文件内容。可以把文件内容赋值给一个变量,通过这个方法可以获得文件的全部内容。
readline-获取文件中的一行
truncate-清空文件,请小心使用
write(stuff)-将stuff写入文件
filename = input("filename >")txt = open(filename,'r')# line1 = txt.readline()print("Opening the file")for line in txt: print(line) for list in line: print(list)
txt.write("hello,hello,hello,hello,hello,hello,hello,hello,hello,hello,hello,hello")
0 0
- python--python读写文件
- Python读写Unicode文件
- python Ini文件读写
- Python读写文件
- Python读写文件
- Python读写ini文件
- Python读写文件
- Python读写文件
- Python文件的读写
- python读写文件
- python文件读写
- [Python]读写文件方法
- python 文件读写操作
- Python文件读写操作
- Python读写文件
- python之读写文件
- python读写文件
- python文件的读写
- cocos2d-x Action 动画
- spring framework源码下载并导入eclipse
- OpenGLES demo - 12. 材质贴图 Texture Mapping
- 《深入理解mybatis原理》 MyBatis事务管理机制
- poj 1789 Truck History (最小生成树)
- Python读写文件
- 定制自己的FancyBox
- Codeforces Round #2A Winner
- 海归进入贬值时代?
- tiny210(s5pv210)移植u-boot(基于 2014.4 版本)——移植u-boot-spl.bin(核心初始化)
- UVA11258- String Partition
- 队列中取最大值操作
- JSP常见的三个编译指令
- 9.1 触摸和手势:触摸的基本概念