/ 作为 python 参数是什么意思?

What does / mean as a python argument?

    def assert_called_with(self, /, *args, **kwargs):
        """assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock."""
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            actual = 'not called.'
            error_message = ('expected call not found.\nExpected: %s\nActual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)

我以前从未在 python 函数的参数中遇到过 / 并且它似乎没有在这里使用(在模拟库的 mock.py 中) .那么它有什么作用呢?

这用于指示 / 之前的任何内容都是仅位置参数。请注意,像 range 这样具有 start, stop, and step 的函数不允许关键字参数,例如,您不能使用 range(stop = 3)。那是因为在函数定义中使用了 /。检查 here 进一步详细说明