The StringIO and cStringIO modules define an object that behaves like a file but reads and writes data from a string buffer.
The following creates a new StringIO object, where s is the initial value (by default, the empty string):
A StringIO object supports all the standard file operations—read(), write(), and so on—as well as the following methods:
Returns the contents of the string buffer before close() is called.
Releases the memory buffer.
The StringIO module defines StringIO as a Python class. cStringIO defines it as an extension type (implemented in C) and provides significantly faster performance.
If an initial argument, s, is given to cStringIO.StringIO(s), the resulting ...