Skip to content

Instantly share code, notes, and snippets.

@pdvyas
Created March 25, 2012 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdvyas/2198372 to your computer and use it in GitHub Desktop.
Save pdvyas/2198372 to your computer and use it in GitHub Desktop.
A trip to Unicode
# -*- coding: utf-8 -*-
a = open('t.txt').read()
# t.txt contains П001
s = [a]
print [d.decode('utf-8') for d in s]
# the line below fails
#print [d.encode('utf-8') for d in s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment