Created
June 15, 2013 17:25
-
-
Save y-gagar1n/5788834 to your computer and use it in GitHub Desktop.
Python - Print cyrillic symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import pprint | |
def pretty_print(object): | |
class decoder_stream: | |
def write(self, s): | |
if s.startswith("'") and s.endswith("'"): | |
s = "'%s'" % s[1:-1].decode('string_escape') | |
elif s.startswith("u'") and s.endswith("'"): | |
s = "u'%s'" % s[2:-1].decode('unicode_escape').encode('utf8') | |
sys.stdout.write(s) | |
pprint.pprint(object, decoder_stream()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment