|
楼主 |
发表于 2023-5-18 14:44:52
|
显示全部楼层
本帖最后由 lzb1001 于 2023-5-18 14:50 编辑
没看懂呢,我上面不是:
>>> abc(5, 6)
Traceback (most recent call last):
File "<pyshell#251>", line 1, in <module>
abc(5, 6)
File "<pyshell#250>", line 3, in abc
return abc()
TypeError: abc() missing 2 required positional arguments: 'x' and 'y'
还是要下面这样?不过下面这样也不行啊
>>> def abc(x, y):
z = x * y
return abc(5, 6)
>>> abc(5, 6)
Traceback (most recent call last):
File "<pyshell#254>", line 1, in <module>
abc(5, 6)
File "<pyshell#253>", line 3, in abc
return abc(5, 6)
File "<pyshell#253>", line 3, in abc
return abc(5, 6)
File "<pyshell#253>", line 3, in abc
return abc(5, 6)
[Previous line repeated 1021 more times]
RecursionError: maximum recursion depth exceeded
>>> abc()
Traceback (most recent call last):
File "<pyshell#255>", line 1, in <module>
abc()
TypeError: abc() missing 2 required positional arguments: 'x' and 'y'
>>> abc
<function abc at 0x000001AC8D8E04C8>
>>> abc()
Traceback (most recent call last):
File "<pyshell#262>", line 1, in <module>
abc()
TypeError: abc() missing 2 required positional arguments: 'x' and 'y'
>>> abc(x, y)
Traceback (most recent call last):
File "<pyshell#263>", line 1, in <module>
abc(x, y)
NameError: name 'x' is not defined
>>> abc(5, 6)
Traceback (most recent call last):
File "<pyshell#264>", line 1, in <module>
abc(5, 6)
File "<pyshell#260>", line 3, in abc
return abc(5, 6)
File "<pyshell#260>", line 3, in abc
return abc(5, 6)
File "<pyshell#260>", line 3, in abc
return abc(5, 6)
[Previous line repeated 1021 more times]
RecursionError: maximum recursion depth exceeded |
|