考虑这行Python代码:
s = "This string has \n\r whitespace"
Run Code Online (Sandbox Code Playgroud)
我该怎么做
print s
给我吗
This string has \n\r whitespace
代替
This string has
whitespace
Run Code Online (Sandbox Code Playgroud)
就像现在一样.
Mic*_*jer 18
你想要原始字符串吗?
s = r"This string has \n\r whitespace"
Run Code Online (Sandbox Code Playgroud)
或者将特殊字符转换为它的表示?
repr(s)
Run Code Online (Sandbox Code Playgroud)