Discuss / Python / 请教

请教

Topic source

风铃草Ella

#1 Created at ... [Delete] [Delete and Lock User]

定义了person函数后 

def person(name, age,**kw):

...     print(name, age, kw)

为什么调入函数时person('Bob', 23, city='Beijing')就可以正常输出,但是如果输入person('Bob', 23, 'Beijing') 就会出错呢?

你的参数里写了**kw,这是个关键字参数,那么就一定要输入一个dict


  • 1

Reply