gpt4 book ai didi

python - 用 C 编写的函数真的不能有 **kwargs 参数吗?

转载 作者:行者123 更新时间:2023-11-28 21:42:12 26 4
gpt4 key购买 nike

是否有我们需要使用的原因:

"test of split".split(" ")

我们不能使用:

"test of split".split(sep=" ")

当然 split 是这样实现的(在 C 中)。但这真的意味着我们无法处理用 C 编写的函数的 **kwargs 吗?

最佳答案

用 C 语言实现的 Python 函数可以被编写为接受关键字参数——例如,sorted(whatever, key=whatever)——但很多函数不是,主要是出于历史原因。

请注意,在 Python 3 上,您现在可以通过关键字将 sep 传递给 str.split

关于python - 用 C 编写的函数真的不能有 **kwargs 参数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44012530/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com