![](/img/trans.png)
[英]For functions that take in an indeterminate number of arguments in python, how to pass in an indeterminate number of arguments
[英]Can there be python functions that take unspecified number of arguments?
python函數是否可以使用未指定數量的參數,例如
myfunc(a, b, c)
myfunc(a, b, c, d, e)
兩者都將在哪里工作?
myfunc(* args,** kw)
* args-接受N個參數
** kw-需要字典(未指定深度)
In [1]: def myfunc(*args):
...: print args
...:
In [2]: myfunc(1)
(1,)
In [3]: myfunc(1,2,3,4,5)
(1, 2, 3, 4, 5)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.