Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是这样做print "Hello world" 我得到这个错误:
print "Hello world"
SyntaxError:无效的语法
然而,我正在使用 Windows 的 Python GUI。
该语法在 Python 3 中不再有效。
File "prog.py", line 1 print "Hello world" ^ SyntaxError: invalid syntax
ideone
在Python 2 print中是一个关键字,您尝试的代码是正确的。
print
# Python 2 print "Hello world"
在Python 3 print中是一个函数,您的代码不再有效。正确的语法如下:
# Python 3 print("Hello world!")
有关的