>>> print r'\u'
>>> print ur'\u'
File "<stdin>", line 1
SyntaxError: (unicode error) 'rawunicodeescape' codec can't decode bytes in position 0-1: truncated \uXXXX
我初学 python 时记得书上说前面有 r 的字符串 \ 没有特殊含义，但后来发现我错了，实际上字符串里的最后一个 \ 还是被莫名其妙转义了（r'\' 和 ur'\' 都会出错，只要引号里最后一个字符是反斜杠）……好吧，这也就算了。但是上面那个例子，unicode 和 str 的行为居然不一样，请问这是 BUG 还是什麼……哪位高手能详细说一下 r'' 和 ur'' 到底是干嘛的？是不是还有其他的反斜杠后的字符会被偷偷地转义？我真的越来越搞不懂了……谢谢~
2.4.1. String literals
When an 'r' or 'R' 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 r"\n" consists of two characters: a backslash and a lowercase 'n'. String quotes can be escaped with a backslash, but the backslash remains in the string; for example, r"\"" is a valid string literal consisting of two characters: a backslash and a double quote; r"\" 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.
When an 'r' or 'R' prefix is used in conjunction with a 'u' or 'U' prefix, then the \uXXXX and \UXXXXXXXX escape sequences are processed while all other backslashes are left in the string. For example, the string literal ur"\u0062\n" consists of three Unicode characters: ‘LATIN SMALL LETTER B’, ‘REVERSE SOLIDUS’, and ‘LATIN SMALL LETTER N’. Backslashes can be escaped with a preceding backslash; however, both remain in the string. As a result, \uXXXX escape sequences are only recognized when there are an odd number of backslashes.