python - 使用 PyScripter 定义函数的 python 中出现无效语法错误

标签 python python-2.7 pyscripter

我正在尝试在 PyScripter IDE 中编写此代码:

def f(a):
    print a

enter image description here

它说:语法错误,语法无效。但是,如果我在 Python Shell 中尝试相同的代码,那就没问题,我可以看到结果

enter image description here

最佳答案

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/

相关文章:

python - 使内存中的数据与长时间运行的 Python 脚本的文件保持同步

python - Pandas series.rename 给出 TypeError : 'str' object is not callable error

python - 更改 PyScripter 以使用不同的 Python 版本

python - 如何通过处理连续换行符等情况来读取csv文件?

python - PIL粘贴图像不模糊

python - 单词列表中最长的单词链

python - 在处理调查数据时,如何合并 pandas 中的列?

python - 在 Python 中使用 format() 方法打印 boolean 值 True/False

python - PyScripter - 更改突出显示选项/配色方案 Python

python - 无法安装 Pandas -InsecurePlatformWarning错误