关键参数

关键参数可以传一个或多个,给予的类型为dict
def person(name,age,**kw):

print("name = ",name,"age = ",age,"others = ",kw)


from guanjiancanshu import person

xinxi = person("tom",16,city="beijing",sex="man")

print(xinxi)


调试结果:

name = tom age = 16 others = {'city': 'beijing', 'sex': 'man'}

None

[Finished in 0.6s]

你可能感兴趣的:(关键参数)