*args
and **kwargs
Just suplement/add a way for defining the default value of arguments that is not assigned in key words when calling the function:
def func(**keywargs):
if 'my_word' not in keywargs:
word = 'default_msg'
print(word)
else:
word = keywargs['my_word']
print(word)
call this by:
func()
func(my_word='love')
you‘ll get:
default_msg
love
read more about *args and **kwargs in python: https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3
Key words arguments in python function
原文:https://www.cnblogs.com/sonictl/p/11486711.html