kwargs.py
#Lorsque vous utilisez args et kwargs ensemble, soyez prudent dans l'ordre
def say_dic(word, *args, **kwargs):
    print(word)
    print(args)
    print(kwargs)
    for k, v in kwargs.items():
        print(k,v)
say_dic('hello', 'Mike',1,  desert='banana', drink='beer')
#Comment réussir après avoir fait un dictionnaire
t = {'math':15, 'science':100}
say_dic('hi', 'Nancy', 2, **t)
Résultat de sortie:
hello
('Mike', 1)
{'desert': 'banana', 'drink': 'beer'}
desert banana
drink beer
hi
('Nancy', 2)
{'math': 15, 'science': 100}
math 15
science 100
        Recommended Posts