0

句子

'I understood that that morning did not work out for her but I would still like to to make an appointment with her. I mean if she does great lashes and it\'s just this one little hiccup in the beginning it\'s well worth it as far as I\'m concerned.'

如何删除转义字符以清理数据?

4

2 回答 2

0

我想,一个简单的re.sub可能工作:

测试

import re

string = '''
I understood that that morning did not work out for her but I would still like to to make an appointment with her. I mean if she does great lashes and it\'s just this one little hiccup in the beginning it\'s well worth it as far as I\'m concerned.
'''

expression = r'\\'

print(re.sub(expression, '', string))

输出

我知道那天早上对她不利,但我仍然想和她预约。我的意思是,如果她的睫毛做得很好,而且一开始只是这个小问题,就我而言,这是非常值得的。

于 2019-11-17T04:32:24.670 回答
0

正确答案在@bryan-oakley 的评论中:没有什么可做的。

作为测试:

s = 'I understood that that morning did not work out for her but I would still like to to make an appointment with her. I mean if she does great lashes and it\'s just this one little hiccup in the beginning it\'s well worth it as far as I\'m concerned.'

assert len(s) == len(s.replace('\'', "'")) # passes
assert s == s.replace('\'', "'") # passes
于 2019-11-18T15:14:42.250 回答