I am trying to few junk characters in my string using the following statement:
desc = string.replace(desc,'“','"')
desc = string.replace(desc,'”','"')
desc = string.replace(desc,'·','.')
Can I write the above 3 statements in to a single statement or atlease the 1st two statements to a single statement.
I can not use any third-party libraries in my project.
Edit @unutbu:
My String looks like below:
This is
'“' my teststring '”'.I want to replace unicode with appropriate HTML not the whole string only with unicode values.
After using the code:
import HTMLParser
text='“ ” ·'
parser=HTMLParser.HTMLParser()
desc=parser.unescape(text)
I am getting only the HTML equivalents , not the string. But I just want to replace the appropriate values keeping everything in Original String.
I expect the out put as below:
This is "my teststring". I want to replace unicode with appropriate HTML not the whole string only with unicode values.