Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. >>> import StringIO
  2. >>> s=StringIO.StringIO()
  3. >>> s.write('hello')
  4. >>> s.getvalue()
  5. 'hello'
  6. >>> import io
  7. >>> s=io.StringIO()
  8. >>> s.write('hello')
  9. Traceback (most recent call last):
  10. File "<stdin>", line 1, in <module>
  11. TypeError: string argument expected, got 'str'
  12. >>> s.write(u'hello')
  13. 5L
  14. >>> s.getvalue()
  15. u'hello'
  16.  
  17. C:UsersJohn>python26python -c"import sys,StringIO;s=StringIO.StringIO();s.wr
  18. ite('hellon');print repr(s.getvalue()), sys.version"
  19. 'hellon' 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
  20.  
  21. C:UsersJohn>python27python -c"import sys,StringIO;s=StringIO.StringIO();s.wr
  22. ite('hellon');print repr(s.getvalue()), sys.version"
  23. '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