python default parameters

def introduct(name,age,job,country="cn")  
      print("-----introduct-------")
      print(name,age,job,country)

introduct("gaohui",21,"python")
introduct("hongyan",23,"java")
introduct("gaohuiaa",23,"it","python1")

At this time, the country is the default parameter. The default parameter must be placed after the non-default parameter. When you do not want the parameter to be the default value, you can write the value in the corresponding position, and the value of the default parameter will be replaced.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326135695&siteId=291194637