How do convert x into y in the following situation?
In [64]: x = '\xe2\x80\x9c random texts.\xe2\x80\x9d '
In [65]: print x
“ random texts.”
In [66]: y = '"random texts."'
In [67]: print y
"random texts."
The question is this: I have a text that has some utf-8 strings, and I want to covert this text into ascii. I will have a table of conversion rules such as
\xe2\x80\x9c : "
\xe2\x80\x9d : "
My first instinct is using regular expression substitution, but I was wondering if there is more pythonic or proper way to achieve this sort of task