擅长:python、mysql、java
<p>所以您不希望有“实际”的换行符,而是希望字符串中的换行符?只需在<code>'\n'</code>中添加第二个斜杠即可转义,<code>'\\n'</code>。或者在字符串前面加上r,使其成为“原始”;在字符串中,反斜杠按字面解释;<code>r'\n'</code>(通常用于正则表达式)。你知道吗</p>
<pre><code>canonical_request = method + r'\n' + canonical_uri + r'\n' + canonical_querystring + r'\n' + canonical_headers
</code></pre>
<p>有关字符串文字的信息,请参阅文档中的<a href="https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals" rel="nofollow">String and byte literals</a>。你知道吗</p>