<p>我有下面的句子,我想从“don'\t”这个词中去掉“\”。为了能用不代替不。你知道吗</p>
<pre><code>a= "To say, "don\'t hate foot" is as dumb as saying "don\'t"
my_dict ={"don't":'do not'}
print(a.replace(r'\\', ""))
out: To say, "don\\\'t hate foot" is as dumb as saying "don\\\'t
print(re.sub(r'\\', "",a))
out: To say, "don\'t hate foot" is as dumb as saying "don\'t
</code></pre>
<p>但我想:</p>
<pre><code>To say, "don't hate foot" is as dumb as saying "don't
</code></pre>
<p>为了申请</p>
<pre><code>' '.join([my_dict.get(word, word) for word in x.split()]))
</code></pre>
<p>我一次清理了很多句子,所以我想一些稳定的,不会影响其他语法</p>