**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
两年前关闭。
Improve this question
它显示错误,但许多人说输出是“学习PY 23”,这怎么可能?!
**def m(name,age=20)
print(name,age)
m("learnPY",23)**
3条答案
按热度按时间mcvgt66p1#
该代码在语法上不是法律的Python代码。
因此,“这段Python代码的输出是什么”这个问题是没有意义的,因为它不是Python代码。
wnvonmuf2#
是的。问题是代码的格式不对。
如果你正确地运行它,它就会工作。这是因为你调用的函数传递了两个参数,这两个参数将被打印。
thigvfpy3#
通过考虑您的代码如下(删除**)
在函数m中,参数age被赋予默认值,只有在调用函数时不传递第二个参数时才应用。
在您的代码中,您使用23,因此输出将为
"LearnPY 23"
如果调用
m("learnPY")
,则输出为"LearnPY 20"