繁体   English   中英

如何在我自己的函数的参数中添加“ args =(…)”?

[英]How do I add “args=(…)” into arguments of my own function?

在scipy中有一个函数quad()

quad(integrand, 0, 1, args=(a,b))

我有自己的函数来使用高斯Legendgre正交求积分,当我将不同函数与参数集成在一起时,我有点累了。 所以问题是:

有没有一种方法可以将参数args=(...)到我自己的函数的参数中?

当然,

def my_function(value1, value2, value3, args=(0,0)):
    print(value1, value2, value3, args)

# call with only 3 values
# it will use args=(0,0) as default
my_function(1,2,3)

# call with 3 values and args
my_function(4,5,6, args=(7,8))

输出:

1 2 3 (0, 0)
4 5 6 (7, 8)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM