有什么方法可以选择函数是否使用默认参数?
Is there any way to choose if a default parameter is used for a function?
例如:
def tune(a=2,b=3,c=4):
return str(a) + " " + str(b) + " " + str(c)
print tune(5, *default*, 7)
这样输出将是:
5 3 7
我应该用什么来代替 *default*
来实现这一点?
使用默认命名参数。明确提到 c
必须取 7
的值
>>> print tune(5, c= 7)
5 3 7
例如:
def tune(a=2,b=3,c=4):
return str(a) + " " + str(b) + " " + str(c)
print tune(5, *default*, 7)
这样输出将是:
5 3 7
我应该用什么来代替 *default*
来实现这一点?
使用默认命名参数。明确提到 c
必须取 7
>>> print tune(5, c= 7)
5 3 7