public
Created

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13
def reopen_stdio_with_encoding(encoding='utf-8'):
import io
import sys
def reopen(file):
file.__init__(file.detach(),
line_buffering=file.line_buffering,
encoding=encoding)
reopen(sys.stdout)
reopen(sys.stderr)
reopen(sys.stdin)
 
reopen_stdio_with_encoding()
print("ほげほげ")

re-init rather than opening other TextIOWrapper.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.