python的StringIO
2017-03-28 11:43
267 查看
有时候需要将
但是有时候不想写到本地,只是要存在电脑内存就好,这样就可以用
information保存在本地,可以这样写:
file = open("filename","w") file.close() file.close()
但是有时候不想写到本地,只是要存在电脑内存就好,这样就可以用
StringIO进行保存:
import StringIO s = StringIO.StringIO() s.write(messages) s.seek(0) getmessages = s.read() s.close()
StringIO可以有按行读取
readlines,按行写入
writelines,一般操作文件写入的方法都会有,具体请看:
相关文章推荐
- Python StringIO与cStringIO
- 使用StringIO 分类: python 小练习 2013-06-14 16:00 233人阅读 评论(0) 收藏
- [笔记]python的StringIO与BytesIO模块
- 【Python】[IO编程]文件读写,StringIO和BytesIO,操作文件和目录,序列化
- Python StringIO与cStringIO
- Python StringIO与cStringIO
- python中的StringIO模块
- python中的StringIO模块
- Python StringIO模块实现在内存缓冲区中读写数据
- python中的StringIO模块——html
- python StringIO
- python中的StringIO和cStringIO模块
- python之StringIO
- python2.7里的StringIO.StringIO与BytesIO有什么区别
- 学习Python:StringIO与cStringIO
- Python StringIO与cStringIO
- python模块之StringIO
- python StringIO
- python模块之StringIO
- python中的StringIO模块