调用函数时可使用的函数类型
def create001(serviceGroup,onlineVersion):
create = create(service_group=serviceGroup,online_version=onlineVersion)
return create
print(create001(serviceGroup="MAC"))
TypeError: create_UpLine_Record() missing 1 required positional argument: 'apollo'
原因:声明函数时为两个参数,调用时传递的是一个参数,所以报错
def create001(serviceGroup,onlineVersion):
create = create(service_group=serviceGroup,online_version=onlineVersion)
return create
print(create001(onlineVersion="v0008",serviceGroup="MAC"))
注意:调用时的名称顺序是不一致的噢
def create001(serviceGroup,onlineVersion="v0008"):
create = create(service_group=serviceGroup,online_version=onlineVersion)
return create
print(create001(serviceGroup="MAC"))
打印结果:serviceGroup="MAC",onlineVersion="v0008",若调用时传递onlineVersion="v0009",则打印serviceGroup="MAC",onlineVersion="v0009"
def create001(args,*kwargs):返回的是元组
def create001(args,**kwargs):返回的是列表
ps:函数的定义为形参,函数的调用为实参