<p><code>r</code>表示该字符串将被视为原始字符串,这意味着将忽略所有转义码</p>
<p>例如:</p>
<p><code>'\n'</code>将被视为换行符,而<code>r'\n'</code>将被视为字符<code>\</code>,后跟<code>n</code></p>
<blockquote>
<p>When an <code>'r'</code> or <code>'R'</code> prefix is present,
a character following a backslash is
included in the string without change,
and all backslashes are left in the
string. For example, the string
literal <code>r"\n"</code> consists of two
characters: a backslash and a
lowercase <code>'n'</code>. String quotes can be
escaped with a backslash, but the
backslash remains in the string; for
example, <code>r"\""</code> is a valid string
literal consisting of two characters:
a backslash and a double quote; <code>r"\"</code>
is not a valid string literal (even a
raw string cannot end in an odd number
of backslashes). Specifically, a raw
string cannot end in a single
backslash (since the backslash would
escape the following quote character).
Note also that a single backslash
followed by a newline is interpreted
as those two characters as part of the
string, not as a line continuation.</p>
</blockquote>
<p>资料来源:<a href="http://docs.python.org/reference/lexical_analysis.html#string-literals" rel="noreferrer">Python string literals</a></p>