In a text file (test.txt) my line looks like this:
Gro\u00DFbritannien
Reading, python speeds up the backslash:
>>> file = open('test.txt', 'r')
>>> input = file.readline()
>>> input
'Gro\\u00DFbritannien'
How can this be interpreted as unicode? decode()and unicode()will not complete the task.
The following code writes Gro\u00DFbritannienback to the file, but I want it to beGroßbritannien
>>> input.decode('latin-1')
u'Gro\\u00DFbritannien'
>>> out = codecs.open('out.txt', 'w', 'utf-8')
>>> out.write(input)
Michi source
share