Django urls.py 中的 r 是什么?

What is r in Django urls.py?

基本的urls.py得到了这样的语句,

(r'^home/$', homeview),

这里的r到底是什么?
它有什么用?

这是 raw strings 的前缀(转义序列被忽略),这对正常的正则表达式很有用。

文档摘录:

When an r' or R' prefix is present, backslashes are still used to quote the following character, but all backslashes are left in the string. For example, the string literal r"\n" consists of two characters: a backslash and a lowercase 'n'

所以 r'\n' 等同于 '\n'