![](/img/trans.png)
[英]How do convert unicode escape sequences to unicode characters in a python string
[英]How to convert a normal string to escape characters in Python?
我想用所有转义字符转换字符串。
输入
string = "Let's do this"
convert(string)
Output
Let\'s do this
谢谢你!
你的问题不清楚。 转义字符是指在某些字符之后添加新行还是只想在字符串中添加反斜杠?
如果您想在 ' 字符之前添加反斜杠,您可以在下面尝试。
new_string = string.replace("'s", "\\'s")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.