【发布时间】:2020-09-23 01:47:05
【问题描述】:
我是 python 新手,问题可能听起来很傻,但我想澄清一下。在学习的过程中,我遇到了 python 允许三引号(“””)作为多行注释和字符串文字的代码。那么 python 如何知道它是作为注释还是字符串文字。
"""This
is treated
as comment
and ignored"""
a = """It is
treated as
string literal"""
print(a)
输出:-
It is
treated as
string literal
【问题讨论】:
-
这很好地解释了为什么它们都是字符串而不是 cmets:stackoverflow.com/questions/7057450/…