ÿþ>>> S = u'A\xC4B' >>> print S AÄB >>> codecs.open('uni.txt', 'w', 'utf-8').write(S) >>> open('uni.txt', 'rb').read() 'A\xc3\x84B' >>> >>> codecs.open('uni.txt', 'r', 'utf-8').read() u'A\xc4B' >>> print codecs.open('uni.txt', 'r', 'utf-8').read() AÄB >>> >>> S u'A\xc4B' >>> S.encode('latin-1') 'A\xc4B' >>> S.encode('utf-8') 'A\xc3\x84B' >>> S.encode('utf-16') '\xff\xfeA\x00\xc4\x00B\x00' >>> >>> X = S.encode('utf-16') >>> X '\xff\xfeA\x00\xc4\x00B\x00' >>> X.decode('utf-16') u'A\xc4B' >>> print X.decode('utf-16') AÄB