Python 2.7.9环境 - 将注释读成多行 - 如何停止?

时间:2015-02-19 20:10:45

标签: python comments development-environment

这是一个简单的生活质量问题,让我发疯。

我倾向于在Notepad ++中编写代码,然后在运行部分/全部时将其复制/粘贴到python.exe中。

旧机器上的Python对评论没有任何问题。

我可以做像

这样的事情
#The next line adds 2 numbers!
x+y = 5
# See how easy!?

但是现在这个Python有一个问题。那失败了。 因为#comment之后的行被认为是评论的延续。

1 个答案:

答案 0 :(得分:0)

这完全不是屏幕截图所示

x+y = 5

永远不是python中的有效语句

也许你的意思是

print x+y #still gonna get an error since you dont define x or y

如果您想要多行注释,请使用docstring

"""
the next line does adding
x+y =5
see how easy a multiline comment is
"""