更新时间:2023-11-13 22:11:04
另一种可以使用转义字符停止python的方法是使用这样的原始字符串:
Another way that you can stop python using escape characters is to use a raw string like this:
>>> print(r"abc\ndef")
abc\ndef
或
or
>>> string = "abc\ndef"
>>> print (repr(string))
>>> 'abc\ndef'
只有使用 repr() / code>是将您的字符串放在单引号中,如果要使用引号
the only proplem with using repr()
is that it puts your string in single quotes, it can be handy if you want to use a quote