dict1 = {
'x': 1,
'y': 2,
'z': 3
}
正确用法:
def mytest(x, y, z):
print("x: {}".format(x))
print("y: {}".format(y))
print("z: {}".format(z))
mytest(**dict1)
# x: 1
# y: 2
# z: 3
错误用法:
def mytest(x, y, m):
print("x: {}".format(x))
print("y: {}".format(y))
print("m: {}".format(m))
mytest(**dict1)
# TypeError: mytest() got an unexpected keyword argument 'z'