Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import StringIO
- >>> s=StringIO.StringIO()
- >>> s.write('hello')
- >>> s.getvalue()
- 'hello'
- >>> import io
- >>> s=io.StringIO()
- >>> s.write('hello')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: string argument expected, got 'str'
- >>> s.write(u'hello')
- 5L
- >>> s.getvalue()
- u'hello'
- C:UsersJohn>python26python -c"import sys,StringIO;s=StringIO.StringIO();s.wr
- ite('hellon');print repr(s.getvalue()), sys.version"
- 'hellon' 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
- C:UsersJohn>python27python -c"import sys,StringIO;s=StringIO.StringIO();s.wr
- ite('hellon');print repr(s.getvalue()), sys.version"
- 'hellon' 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement