在Python中出现了"function is not defined"错误。
- 论坛
- 在Python中出现了"function is not defined"错误。
11 浏览
在Python中出现了"function is not defined"错误。
我正在尝试在Python中定义一个基本函数,但是当我运行一个简单的测试程序时,总是会出现以下错误;
>>> pyth_test(1, 2) Traceback (most recent call last): File "", line 1, in pyth_test(1, 2) NameError: name 'pyth_test' is not defined
这是我用于这个函数的代码;
def pyth_test (x1, x2): print x1 + x2
更新:我已经打开了名为pyth.py的脚本,然后在解释器中输入pyth_test(1,2)时出现错误。
谢谢帮助。(对于这个基本问题我道歉,我以前从未编程过,现在正在尝试作为一种爱好学习Python)