A text stream using an in-memory text buffer. It inherits from TextIOBase.
class io.StringIO(initial_value='', newline='\n')
import io
output = io.StringIO()
output.write('First line.\n')
print('Second line.', file=output)
Retrieve file contents -- this will be
'First line.\nSecond line.\n'
contents = output.getvalue()
Close object and discard memory buffer --
.getvalue() will now raise an exception.
output.close()