[英]Why can't I run my codes in Python Shell?
def thisisfun(x,y,z):
x=2
y=3
z=4
print('AHHHHA')
thisisfun(333,"annoy",2142125)
If it is with the last line, then after I clicked on Execute Current File
it actually prints AHHHHA
But when I attempted to have thisisfun(333,"annoy",2142125) in Python Shell (without the last line), it says name 'thisisfun' is not defined
I dont know what happened to my WingIDE...:( Help.. 如果在最后一行,那么在我单击“ Execute Current File
它实际上会打印AHHHHA
但是,当我尝试在Python Shell(无最后一行)中使用thisisfun(333,“ annoy”,2142125)时,其name 'thisisfun' is not defined
我不知道我的WingIDE ... :(帮助..
You need an empty line after your function definition or the parser gets confused: 您需要在函数定义后留空行,否则解析器会感到困惑:
def thisisfun(x,y,z):
x=2
y=3
z=4
print('AHHHHA')
thisisfun(333,"annoy",2142125)
This makes it clear that the function call is not part of the function itself. 这清楚表明函数调用不是函数本身的一部分。
Execute Current File runs that file outside of the debugger until it terminates. 执行当前文件在调试器外部运行该文件,直到终止。 This does not happen in the context of the Python Shell's runtime environment, but in a separate process. 这并不在Python壳牌的运行时环境的背景下发生的,而是在一个单独的进程。 If you want to work with this in the Python Shell then use Evaluate File in Python Shell in the Source menu. 如果要在Python Shell中使用此功能,请在“源”菜单中使用“ Python Shell中的评估文件”。 After that, thisisfun is defined in the Python Shell's environment until you restart it from its Options menu. 之后,在Python Shell的环境中定义thisisfun,直到您从其“选项”菜单重新启动它为止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.