Custom Search

SUBSCRIBE

SUBSCRIBE : 300 + Free Video Tutorials Programming (Python, golang, Julia), DevOps

Wednesday, March 9, 2016

python StringIO read and write strings as files

>>>from cStringIO import StringIO

>>>buf=StringIO()

>>>def write_to_buffer(buf):
            for i in range(1,10):
                buf.write(str(i))


>>>buf.getvalue()

>>>write_to_buffer(buf)

>>>buf.getvalue()


No comments:

Post a Comment