python got an unexpected keyword argument

 
The following exception is simulated:

 

def add(x,y):
   return x+y

print(add(bbb=3))

report errors:

TypeError: add() got an unexpected keyword argument ‘bbb’
 
reason:

The add function has no parameter BBB and passes an unknown parameter BBB

 
resolvent:

def add(x,y,*args,**kwargs):
   return x+y

print(add(bbb=3))

This is not a mistake

def add(**kwargs):
   return 4

print(add(pre=4,bbb=3))

 


Read More: