1

My code loads the title of a youtube video.

I have problem with accented and special characters

For Example: i'm getting this title in string format: LES \\xc9TUDES DE M\\xc9DECINE

I need to remove the double backslash to get LES \xc9TUDES DE M\xc9DECINE

So i can be able to print it correctly in python 3:

print(`LES \xc9TUDES DE M\xc9DECINE`)
>>LES ÉTUDES DE MÉDECINE

Thank you

HazimoRa3d
  • 517
  • 5
  • 12

1 Answers1

1

You can use the literal_eval function like so:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import ast
>>> ast.literal_eval("'LES \\xc9TUDES DE M\\xc9DECINE'")
'LES ÉTUDES DE MÉDECINE'
Noctis Skytower
  • 21,433
  • 16
  • 79
  • 117