Python Syntax Error

半世苍凉 提交于 2019-12-12 02:30:06

问题


I'm on Windows and I'm using PyScripter. For some reason everything results in a syntax error, even code that very obviously does not have a syntax error. For example,

print 6

gets a syntax error, as does,

a = 6
print a

list = (1, 2, 7, 3)
print list

print 3 + 3

or any other code I can think of that involves printing. Did I download Python wrong, am I setting it up wrong, or what?


回答1:


Are you using Python 3? The print function in Python three must use parentheses:

a = 6
print(a)



回答2:


I think you are installed python 3.x in your machine and writing python 2.x syntax in it. Try to install python 2.x or use python 3.x syntax while writing. :) Thank you



来源:https://stackoverflow.com/questions/17581532/python-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!