在 python3.8 中新增了一个标识符 \ 用来说明 \ 以前参数必须使用正确的入参位置来指定,与 * 后只能使用关键字指定类似,两个符号都仅仅只是说明,并不需要多传入参数
例如:
>>> def func1(a, /, b, *, c):
... print(a, b, c)
...
>>> func1(1, 2, c=2)
1 2 2
>>> func1(a=1, b=2, c=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: func1() got some positional-only arguments passed as keyword arguments: 'a'
即 a 不能使用 关键字指定赋值
>>> func1(1, b=2, 3)
File "<stdin>", line 1
func1(1, b=2, 3)
^
SyntaxError: positional argument follows keyword argument
即 c 必须使用 关键字指定赋值