开发者

Eclipse (with Pydev) keeps throwing SyntaxError

My code:

print "Hello World!"

I even tried adding a semicolon behind, but everytime I save and run (as Python run) it says:

File "E:\Software\Eclipse\Workspace\Python1\src\main.py", line 1 print "Hello World!";

SyntaxError: invalid syntax

I have no id开发者_JAVA技巧ea why.


What version of Python are you using? Python 2.X has print as a keyword, but Python 3.X only has print() as a function - you'd need to use print("Hello, World!") instead.


This is kind of a longshot but - if you're running python 3.0 that is invalid syntax. Try

print("Hello World!") 

to see if this is the case.


In Python, indentation is really important... Have you check your indentation? Also, lose the ; (don't need it).

correct:

print("hello") or print "hello" (for < 3.0)

not correct:

...print("hello") or print "hello" (for < 3.0)

where . denotes spaces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜