用 C 编写的函数真的不能有 **kwargs 参数吗?
Is it true that functions written in C cannot have **kwargs arguments?
有没有我们需要使用的原因:
"test of split".split(" ")
我们不能使用:
"test of split".split(sep=" ")
当然split就是这样实现的(在C中)。但这真的意味着我们无法处理用 C 编写的函数 **kwargs
吗?
Python 在 C 中实现的函数可以 编写为采用关键字参数 - 例如,sorted(whatever, key=whatever)
- 但其中许多函数不会,主要是由于历史原因。
请注意,在 Python 3 上,您现在可以通过关键字将 sep
传递给 str.split
。
有没有我们需要使用的原因:
"test of split".split(" ")
我们不能使用:
"test of split".split(sep=" ")
当然split就是这样实现的(在C中)。但这真的意味着我们无法处理用 C 编写的函数 **kwargs
吗?
Python 在 C 中实现的函数可以 编写为采用关键字参数 - 例如,sorted(whatever, key=whatever)
- 但其中许多函数不会,主要是由于历史原因。
请注意,在 Python 3 上,您现在可以通过关键字将 sep
传递给 str.split
。