[英]How do you pass arguments from one function to another?
Sorry for the newbie question guys, but I'm relatively new to python. 对不起新手问题的家伙,但我对python相对较新。 I want to write a function that passes keyword and value arguments into another function:
我想编写一个将关键字和值参数传递给另一个函数的函数:
eg 例如
def function_that_passes_arguments(arguments):
some_other_function(arguments)
so when I call the first function they are passed into the second... eg 所以当我调用第一个函数时,它们会被传递给第二个函数......例如
function_that_passes_arguments(arg1=1, arg2=2)
is effectively 是有效的
some_other_function(arg1=1, arg2=2)
The argument names will change so it is important that I pass both keyword and value from one function to another. 参数名称将更改,因此将关键字和值从一个函数传递到另一个函数非常重要。
Accept *args, **kwargs
and pass those to the called function: 接受
*args, **kwargs
并将它们传递给被调用的函数:
def function_that_passes_arguments(*args, **kwargs):
some_other_function(*args, **kwargs)
In both places you can also use regular arguments - the only requirement is that the *
and **
arguments are the last ones. 在这两个地方你也可以使用常规参数 - 唯一的要求是
*
和**
参数是最后一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.