有没有更pythonic的方法来做到这一点?
if condition: return f(x, y, z=1) else: return f(x, y)
有条件地构建你的 kwargs:
kwargs = {} if condition: kwargs['z'] = 1 return f(x, y, **kwargs)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
点击生成二维码
我来说两句