I开发者_高级运维n 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. :)
str.replace()
doesn't replace the original string, it just returns a new one.
Do:
cell_info = cell_info.replace('“','"').replace('”','"')
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
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.
精彩评论