<分区>
我在这里很困惑,即使原始字符串将每个 \
转换为 \\
但是当这个 \
最后出现时它会引发错误.
>>> r'so\m\e \te\xt'
'so\\m\\e \\te\\xt'
>>> r'so\m\e \te\xt\'
SyntaxError: EOL while scanning string literal
更新:
这现在包含在 Python FAQs 中还有:Why can’t raw strings (r-strings) end with a backslash?