Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような不特定の数の引数を取る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)