def func(a,b=0,*c,**d):
print(a)
print(b)
print(c)
print(d)
func(1,2,3,4,5,name="tom",age=18)
#结果:
# 1
# 2
# (3, 4, 5)
# {'name': 'tom', 'age': 18}
“””
a***必填*参数
b**可缺省参数**,传值的话b就有值,不传的话就是0
c**可变数量**参数,可以0个,可以多个
d**关键字可变数量**参数
“”“
def func(*a):
print(type(a))
total = 0
for one in a:
total += one
print(total)
func(1,2,3) #任意数字的求和
结果: