*args
:
传递一个非键值对的可变数量的参数列表给一个函数。
1
2
3
4
5
6
7
8
9
10
11
12 def test_var_args(f_arg, *argv):
print("first normal arg:", f_arg)
for arg in argv:
print("another arg through *argv:", arg)
test_var_args('yasoob', 'python', 'eggs', 'test')
# output:
# first normal arg: yasoob
# another arg through *argv: python
# another arg through *argv: eggs
# another arg through *argv: test