Front deep_learning_Function_list variable asterisk in front of the dictionary variable plus two asterisks

List an asterisk in front of the role is to unlock the list into two independent parameters passed to the function,

Preceded by two asterisks dictionary, the dictionary is to unlock the element as independent parameter.

    def add(a, b):
    return a+b
     
    data = [4,3]
    print add(*data)
    #equals to print add(4, 3)
    data = {'a' : 4, 'b' : 3}
    print add(**data)
    #equals to print add(4, 3)

 

Transfer: https://blog.csdn.net/liuweizj12/article/details/79893673

Guess you like

Origin www.cnblogs.com/0405mxh/p/11655388.html