>>> dct = {"1":2,"2":1}
>>> def f(**kwds):
... print kwds
...
>>> f(dct)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes exactly 0 arguments (1 given)
>>> f(**dct)
{'1': 2, '2': 1}
>>> f(a=1,b=3)
{'a': 1, 'b': 3}
>>> **dct
File "<stdin>", line 1
**dct
^
SyntaxError: invalid syntax
>>> ary = (1,2,3)
>>> def ff(*args):
... print ary
...
>>> ff(ary)
(1, 2, 3)
>>> ff(4,5,6)
(1, 2, 3)
Python中任意函数参数问题
最新推荐文章于 2023-01-07 21:40:22 发布