看了一下,都是源码用的多,很少有自己写这种可变参数啊,大家平时用这种吗?
def test_kwargs(first, *args, **kwargs):
print 'Required argument: ', first
for v in args:
print 'Optional argument (*args): ', v
for k, v in kwargs.items():
print 'Optional argument %s (*kwargs): %s' % (k, v)
test_kwargs(1, 2, 3, 4, k1=5, k2=6