I have a file containing
foo = "Gro\xdfbritannien"
I'm using the following, but it always displays the original text with the \x
import codecs
f = codecs.open('myfile', 'r', 'utf8')
for line in f:
print line
print line.encode('utf-8')
print line.decode('utf-8')
I can't see how to display the proper encoded text, as when I'm doing
>>> print u'Gro\xdfbritannien'
Großbritannien
Any hint would be appreciated!
xin it, you'll need to parse the string literal with something likedecode('string-escape').