|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
嵌套函数如下:
def test1(x):
def test2(y):
result = x + y
return result
return test2()
shell下访问始终提示少test2的y,求指导要如何运行该函数test1()????
>>> test1(2)
Traceback (most recent call last):
File "<pyshell#36>", line 1, in <module>
test1(2)
File "C:\Users\Administrator\Desktop\ff.py", line 6, in test1
return test2()
TypeError: test2() missing 1 required positional argument: 'y'
>>> test1(2)(3)
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
test1(2)(3)
File "C:\Users\Administrator\Desktop\ff.py", line 6, in test1
return test2()
TypeError: test2() missing 1 required positional argument: 'y' |
|