擅长:python、mysql、java
<p>另一种阻止python使用转义字符的方法是使用如下原始字符串:</p>
<pre><code>>>> print(r"abc\ndef")
abc\ndef
</code></pre>
<p>或者</p>
<pre><code>>>> string = "abc\ndef"
>>> print (repr(string))
>>> 'abc\ndef'
</code></pre>
<p>使用<code>repr()</code>的唯一问题是它将字符串放在单引号中,如果您想使用引号,它会很方便</p>