将字符“\”替换为“\\”?
Replace character "\" with "\\"?
当我从 Windows 资源管理器复制路径时,它将采用这种 "C:\Users"
表示法,而我实际上想要 "C:\Users"
。有什么功能可以帮我替换吗?
我已经想到可以使用 codecs.decode(file_path, "unicode_escape")
解决相反的方法,但不确定这个方向。
如 所述,使用原始字符串:
In this case, use a raw string: r"<paste path here>"
. Otherwise, if you paste it into input
or a UI textfield, Python will do the escaping for you.
当我从 Windows 资源管理器复制路径时,它将采用这种 "C:\Users"
表示法,而我实际上想要 "C:\Users"
。有什么功能可以帮我替换吗?
我已经想到可以使用 codecs.decode(file_path, "unicode_escape")
解决相反的方法,但不确定这个方向。
如
In this case, use a raw string:
r"<paste path here>"
. Otherwise, if you paste it intoinput
or a UI textfield, Python will do the escaping for you.