从教程:是 “””为原始字符串语法糖
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 "
语义上完全相同吗?
“因此搜索文档对我来说不是一个真正的选择” - 您总是可以先尝试,然后在失败时再来。 –