我编写了一段代码,将PHP的脱节转换为有效的Python [反斜杠]转义:

cleaned = stringwithslashes
cleaned = cleaned.replace('\\n', '\n')
cleaned = cleaned.replace('\\r', '\n')
cleaned = cleaned.replace('\\', '')

我如何凝结呢?

最佳答案

不能完全确定这是您想要的,但是..

cleaned = stringwithslashes.decode('string_escape')

关于Python版本的PHP的反斜杠,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13454/

10-09 04:13