0

I have a text with values as \xe1, \xed, etc. and I want the text with accent mark i.d. á, í.

test = 'Bicicleta en Bogot\\xe1'
test1 = test.encode('utf-8')

print test1
Bicicleta en Bogot\xe1

output Bicicleta en Bogot\xe1

I want output: Bicicleta en Bogotá

Sandra Guerrero
  • 313
  • 1
  • 3
  • 12
  • Is this python2? That matters for text related stuff. Please add a tag for it. – Mad Physicist Jul 07 '19 at 01:45
  • Add a `u` before the string – Mad Physicist Jul 07 '19 at 01:45
  • You have actually the four characters \, x, e and 1 in your string, not the single character `E1` inserted by an escape sequence. Cf. `len('Bogot\\xe1')` vs. `len('Bogot\xe1')`. – lenz Jul 07 '19 at 08:20
  • If your input actually looks like what you showed, then the linked answer doesn't help you. Instead, you should try `test.decode('unicode_escape')`. – lenz Jul 07 '19 at 08:25

0 Answers0