我想要类似以下功能的东西:
calc_map(img_in, img_height, img_width, mapping = np.zeros((image_height, image_width)))
[function body]
显然映射的默认参数不可能依赖于该函数中的其他参数。在不使用 image_height 和 image_width 作为全局的情况下,还有另一种方法吗?
我想把它放在我的函数中:
calc_map(img_in, img_height, img_width)
mapping = np.zeros((image_height, image_width))
[function body]
但我还需要将一个已经存在的映射放入函数中并且没有覆盖它..
感谢任何帮助,问候,eli
None
在函数签名中设置默认值,然后将其替换为您想要的任何内容:
def calc_map(img_in, img_height, img_width, mapping = None)
if mapping is None:
mapping = np.zeros((image_height, image_width))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句