我编写了一段代码将PHP的striplashes转换为有效的Python [反斜杠]转义:
cleaned = stringwithslashes
cleaned = cleaned.replace('\\n', '\n')
cleaned = cleaned.replace('\\r', '\n')
cleaned = cleaned.replace('\\', '')
我怎么能压缩它?
解决方法:
不完全确定这是你想要的,但..
cleaned = stringwithslashes.decode('string_escape')