擅长:python、mysql、java
<p>使用<code>'''</code>或<code>"""</code><a href="http://docs.python.org/2/reference/lexical_analysis.html#string-literals" rel="noreferrer">triple-quoted string literal</a>:</p>
<pre><code>longstring = """\
You can use multiple lines
and newlines
are preserved
"""
</code></pre>
<p>我在开头的三重引号后面使用了一个<code>\</code>换行符,以避免将第一行放在开头的引号后面。因此,字符串从<code>You</code>开始(前面没有换行符):</p>
<pre><code>>>> longstring = """\
... You can use multiple lines
... and newlines
... are preserved
... """
>>> print longstring
You can use multiple lines
and newlines
are preserved
</code></pre>