Skip to content

Instantly share code, notes, and snippets.

@tomoemon
Created February 18, 2013 16:28
Show Gist options
  • Save tomoemon/4978592 to your computer and use it in GitHub Desktop.
Save tomoemon/4978592 to your computer and use it in GitHub Desktop.
python various encoding
-*- coding: utf-8 -*-
import sys
import locale
sys.stdout.write(repr(sys.stdout.encoding) + "\n") # on redirecting, set None
sys.stdout.write(repr(sys.getdefaultencoding()) + "\n") # used as default encoding when encoding or decoding
sys.stdout.write(repr(sys.getfilesystemencoding()) + "\n")
sys.stdout.write(repr(locale.getpreferredencoding()) + "\n")
sys.stdout.write(u"あいうえお\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment