从一个教程:
print """ Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to """
产生以下输出:
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
hello = r"This is a rather long string containing\n\
several lines of text much as you would do in C."
print hello
会打印:
This is a rather long string containing\n\
several lines of text much as you would do in C.
这向我表明,"""
符号只是原始字符串的语法糖。我对 python 完全陌生,所以搜索文档对我来说并不是一个真正的选择。
""" text """
和r" text "
语义上完全相同吗?