1

I have a situation reading some files.

This is my code at the moment:

#Before this code no relevant to the problem
with open(path+r"\\"+file) as js:
    lines = js.readlines()
    for line in lines:
        if('"text" : ' in line):
            line = line.replace('"text" : ',"")
            for word in line.split():
                pass

Word is already a string, but there are some strings, like 'compa\u00F1eras' that should be 'compañeras'. I need to change the Unicode characters to their representation (I'm working with spanish text, so I expect to see characters with accents marks, like á or ó).

What can I do?

Thanks in advance.

Mangu
  • 3,005
  • 2
  • 25
  • 39
  • 1
    Sounds like you have *JSON* text perhaps? I suspect you should be using the `json` library here for the whole document rather than decode line-by-line, but you didn't provide enough context for us to determine this. – Martijn Pieters Aug 27 '16 at 14:36
  • Also see [how do I .decode('string-escape') in Python3?](https://stackoverflow.com/a/14820462) – Martijn Pieters Aug 27 '16 at 14:38

0 Answers0