|

楼主 |
发表于 2023-5-15 21:39:21
|
显示全部楼层
1、FunX(2)(3)这样还不行?
2、另外如果下面这样也不对:
def FunX(x):
def FunY():
return x * y
return FunY()
>>> FunX(8)
Traceback (most recent call last):
File "<pyshell#58>", line 1, in <module>
FunX(8)
File "<pyshell#57>", line 4, in FunX
return FunY()
File "<pyshell#57>", line 3, in FunY
return x * y
NameError: name 'y' is not defined
>>> i = FunX(8)
Traceback (most recent call last):
File "<pyshell#59>", line 1, in <module>
i = FunX(8)
File "<pyshell#57>", line 4, in FunX
return FunY()
File "<pyshell#57>", line 3, in FunY
return x * y
NameError: name 'y' is not defined
>>> i
Traceback (most recent call last):
File "<pyshell#60>", line 1, in <module>
i
NameError: name 'i' is not defined
>>> type(i)
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
type(i)
NameError: name 'i' is not defined
>>> i(5)
Traceback (most recent call last):
File "<pyshell#62>", line 1, in <module>
i(5)
NameError: name 'i' is not defined
>>> FunX(8)(5)
Traceback (most recent call last):
File "<pyshell#63>", line 1, in <module>
FunX(8)(5)
File "<pyshell#57>", line 4, in FunX
return FunY()
File "<pyshell#57>", line 3, in FunY
return x * y
NameError: name 'y' is not defined |
|