Reputation:
In my utf-8 encoded file, there are curly quotes (“”).
How do I replace them all with normal quotes (")?
cell_info.replace('“','"')
cell_info.replace('”','"')
did not work. No error message.
Thank you. :)
Upvotes: 5
Views: 11375
Reputation: 1911
other way that work with my code is this:
cell_info = cell_info.replace(u'\u201c', '"').replace(u'\u201d', '"')
this because i already have this # -*- coding: utf-8 -*-
at the top of my script
Upvotes: 6
Reputation: 12580
cell_info = cell_info.replace('“','"').replace('”','"')
The replace method return a new string with the replacement done. It doesn't act directly on the string.
Upvotes: 1
Reputation: 85458
str.replace()
doesn't replace the original string, it just returns a new one.
Do:
cell_info = cell_info.replace('“','"').replace('”','"')
Upvotes: 13