python函数入参缺省书写

在书写python函数时,有时需要给某几个入参设置默认值,这里讲一讲python入参缺省的书写规范。

缺省的入参需要放在参数列表的最后

def test(arg1,arg2,arg3=0,arg4=True)

调用入参缺省的函数时,若要改变缺省入参的值,则需要指定

test('a','b',arg4=False,arg3=1)

猜你喜欢

转载自blog.csdn.net/qq_39985298/article/details/88863120