【发布时间】:2015-03-28 12:50:36
【问题描述】:
当语法错误出现以下代码时,我正在使用 Python 中的简单 if-else 语句。
"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"
"""
Another multi-line comment in Python
"""
else:
print "Good Morning!"
此代码在“else”关键字处出现语法错误。
以下代码却没有:
"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"
#One single line comment
#Another single line comment
else:
print "Good Morning!"
谁能告诉我为什么会这样?为什么 Python 解释器不允许 if-else 语句之间有多行 cmets?
【问题讨论】:
-
"""This is a string, not a comment""" -
如何在 Python 中编写多行注释? Multi-Line Comments in Python
标签: python if-statement comments