test(1, b=2, c=3)
test(*(1,), b=2, c=3)
# 错误
test(a=1, b=2, c=3)
1 2 3
1 2 3
1 2 3
test(a=1,...b=2, c=3)
TypeError: test() got some positional-only arguments passed as keyword arguments: 'a'
报错信息...a, *, b, c):
return a + b + c
# 正确
f1(1, b=2, c=3)
f1(1, **{"b": 2, "c": 3})
# 错误
f1(1, 2, c=3...)
# 输出结果
6
6
f1(1, 2, c=3)
TypeError: f1() takes 1 positional argument but 2 positional arguments...(and 1 keyword-only argument) were given
报错信息:接受1个位置参数,但提供了2个位置参数(和1个仅限关键字的参数)
在 * 形参后的参数只能通过关键字参数传递