[英]Is there any way to use default parameters out of order without having to pass them explicitly in a Python function?
For example, I have this function: 例如,我有以下功能:
def do_something(a=None, b=None, c=None):
pass
Let's say I want to pass only the last parameter to this function, so the call of this function would be like this: do_something(None, None, 15)
. 假设我只想将最后一个参数传递给此函数,所以此函数的调用将像这样:
do_something(None, None, 15)
。 Is there anyway to do this without passing the first two parameters explicitly? 无论如何,没有显式地传递前两个参数就可以做到这一点?
是的,只是发出
do_something(c=15)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.