Python python function parameters: Keyword parameters

# Keyword parameter 
'' ' keyword parameter represents any number of passed parameters including a parameter name, the keywords automatically assembled as a dict parameters inside the function
     ' '' 

DEF Student (name, Sex, ** Keywords):
     Print ( ' name: ' , name)
     Print ( ' Sex: ' , Sex)
     Print ( ' Keywords: ' , Keywords) 

Student ( ' Chris ' , ' MALE ' )
 # name: Chris 
# Sex: MALE 
# Keywords: {} 

# * * keywords corresponding to the required argument can be converted into dict 
Student (' Chris ' , ' MALE ' , City = ' Shanghai ' , Profession = ' ENGINEER ' )
 # name: Chris 
# Sex: MALE 
# Keywords: { 'City': 'Shanghai', 'Profession': 'ENGINEER'} 

'' ' keyword parameters are spread function, in some particular functions to be used, such as user registration, can be collected to fill a field
    ' ''

 

Guess you like

Origin www.cnblogs.com/pickKnow/p/10936525.html