How to remove curly quotes?

My utf-8 encoded file has curly quotes ("").

How to replace them with regular quotation marks (?)?

cell_info.replace('"','"')
cell_info.replace('"','"')

does not work. There is no error message.

Thank.:)

+3
source share
3 answers

str.replace() does not replace the original string, it just returns a new one.

do:

cell_info = cell_info.replace('"','"').replace('"','"')
+7
source

another way that works with my code is the following:

cell_info = cell_info.replace(u'\u201c', '"').replace(u'\u201d', '"')

because I have this "# -encoding: utf-8 -" at the top of my script

+3
source
cell_info = cell_info.replace('"','"').replace('"','"')

The replace method returns a new line with a complete replacement. It does not act directly on the string.

0
source

Source: https://habr.com/ru/post/1758484/


All Articles