Sunday, August 9, 2009

how to print to string in Python

Here's how to do it. You have to use the StringIO module.


import StringIO

datastring = StringIO.StringIO()
...
print >>datastring, " Hello string."

No comments: