#标准库: Stringio provides the class file API text buffer
#作用: Can handle in-memory text, there are 2 different implementations: The CSTRINGIP version increases speed with C writing, Stringio provides portability with Python, and cstringio constructs large strings for better performance than other string connections
#示例
Try
From Cstringio import Stringio
Except
From Stringio import Stringio
#写入缓冲区
Out=stringio ()
Out.write (' buffer. ')
Print >>out, ' and so this. '
#读写
Print Out.getvalue ()
Print out.close () #dirsard buffer
Ipt=stringio (' Value buffer ')
#read from the buffer
Print Ipt.read ()
#这边使用read (), but you can also use the Readlin (), ReadLines () method, the Stringio class provides a seek () method that jumps through the buffer while reading the text, which is useful for rotation if a forward parsing algorithm is made
#StringIO官方标准地址: Https://docs.python.org/2.7/library/stringio.html?highlight=stringio#module-StringIO and https:/ /docs.python.org/2.7/library/stringio.html?highlight=stringio#module-cstringio
Python Stringio standard library Basics Learning