如何删除卷曲引号?

3 python

在我的utf-8编码文件中,有引号("").

如何用普通引号(")替换它们?

cell_info.replace('“','"')
cell_info.replace('”','"')
Run Code Online (Sandbox Code Playgroud)

不工作.没有错误消息.

谢谢.:)

Nul*_*ion 9

str.replace() 不替换原始字符串,只返回一个新字符串.

做:

cell_info = cell_info.replace('“','"').replace('”','"')
Run Code Online (Sandbox Code Playgroud)


eli*_*n3t 5

使用我的代码的另一种方式是这样的:

cell_info = cell_info.replace(u'\u201c', '"').replace(u'\u201d', '"')
Run Code Online (Sandbox Code Playgroud)

这是因为我准备在脚本的顶部使用此“#-- 编码:utf-8--