I am trying replace all consecutive single quote pairs with double quotes.
Code:
text.replace('\'\'','\"')
But this doesn't seem to work.
Background: I am extracting article text from stored .html files using Goose.
article = extractor.extract(raw_html=html) #extracts content
text = (unidecode(article.cleaned_text)) #changes encoding
Here article is in unicode and text in str. I am using Python 2. I try to print the text.
print text
Output:
''Several people were crushed or trampled to death,'' the police said in a statement.
instead of
\'\'Several people were crushed or trampled to death,\'\' the police said in a statement.
This is somewhat confusing to me. My code would work if it was in the second format. I don't understand how the string is stored even given the quotes are not preceeded by \.