64- a function of the number of parameters is not fixed

Not fixed transmission parameters:

DEF func1 (* args):   # * args represents a tuple. 
    Print (args) 

DEF func2 (** kwargs):   # ** represents kwargs a dictionary. 
    Print (kwargs) 

DEF func3 (X, Y):
     Print (X * Y) 

DEF Func4 (name, Age):
     Print ( " % S% S IS years Old " % (name, Age)) 

IF  the __name__ == ' __main__ ' : 
    func1 () 
    func1 ( 10 ) 
    func1 ( 10, ' Bob ' )  
    func2 ()
    func2 (name = ' Bob ' , Age = 25 ) 
    func3 ( * [10,5])   # time of the call, * indicates the data type of later disassembled. 
    Func4 (** { ' name ' : ' Bob ' , ' Age ' : 25})   # name = 'Bob', Age = 25.

Output results:

()
(10,)
(10, 'bob')
{}
{'name': 'bob', 'age': 25}
50
bob is 25 years old

 

Guess you like

Origin www.cnblogs.com/hejianping/p/10956352.html