python3中的缺省参数和命名参数

def test(a,b):
    result=a+b
    print("result=%d"%(a+b))
test(11,22)
test(11,1)
test(22,1)
def test1(a,b=1):#b=1 是一个缺省参数
    result=a+b
    print("result=%d"%(a+b))
test1(11)
test1(11,b=22) #此处b=22 是一个命名参数

 

posted @ 2019-03-31 20:54  い昔阳ゾ  阅读(630)  评论(0编辑  收藏  举报