1、使用关键字时甚至可以打乱参数传递次序。
overspeed_rate(min=80,max=100,current=100) >>>overspeed_rate(min=80,max=100,current=100) 0
2、在定义函数时,如果参数列表中的某个参数使用**参数名称,则该参数可以接受所有关键词参数。
defecho(string,**keywords): print(string) forkwinkeywords: print(kw,":",keywords[kw]) >>>echo(‘hello’,today=‘2019-09-04’,content=‘function’,section=3.6)
以上就是python关键字参数的多种使用,希望对大家有所帮助。
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
下一篇