我正在尝试在 PyScripter IDE 中编写此代码:
def f(a):
print a
它说:语法错误,语法无效
。但是,如果我在 Python Shell 中尝试相同的代码,那就没问题,我可以看到结果
最佳答案
Pyscripter 默认使用最新版本的 python 可用 因此,您可能在 pyscripter 上使用 python 3,其中 print
是一个函数,因此请尝试:
def f(a):
print(a)
要将 pyscripter 设置为使用 python 2,请将其添加到您的 pyscripter 快捷方式中,编辑 target
字段,如下所示:
"path_2_PyScripter.exe" --PYTHON27
关于python - 使用 PyScripter 定义函数的 python 中出现无效语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20585038/