为什么删除反斜杠也会删除反斜杠后面的一些字符? (Python)[关闭]

问题描述 投票:0回答:0

例如,我想删除反斜杠:

Reuters - Venezuelans turned out early\and in large numbers on Sunday to vote in \a historic referendum\that will either remove left-wing President Hugo Chavez from\office or give him a new mandate to govern for the next two\years.

我已经尝试了

re.sub()
str.replace()

但是两种方法都返回:

Reuters - Venezuelans turned out earlynd in large numbers on Sunday to vote in  historic referendum hat will either remove left-wing President Hugo Chavez from office or give him a new mandate to govern for the next two years.

为什么“and”少了“a”,“a”少了“that”,“that”少了“t”,但是“office”和“years”完好无损?

python regex string replace backslash
© www.soinside.com 2019 - 2024. All rights reserved.