fork download
  1. #!/usr/bin/env python2
  2. """Demonstrate that raw_input() can return Unicode."""
  3. import sys
  4.  
  5. class UnicodeFile:
  6. def readline(self, n=-1):
  7. return u'\N{SNOWMAN}'
  8.  
  9. sys.stdin = UnicodeFile()
  10. s = raw_input()
  11. print type(s)
  12. print s
Runtime error #stdin #stdout #stderr 0.02s 9016KB
stdin
this is not read
stdout
<type 'unicode'>
stderr
Traceback (most recent call last):
  File "prog.py", line 12, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2603' in position 0: ordinal not in range(128)