是否有我们需要使用的原因:
"test of split".split(" ")
我们不能使用:
"test of split".split(sep=" ")
当然 split 是通过这种方式实现的(在 C 中)。但这真的意味着我们无法处理**kwargs
用 C 编写的函数吗?
用 C 实现的 Python 函数可以编写为采用关键字参数——例如,sorted(whatever, key=whatever)
——但其中许多没有,主要是由于历史原因。
请注意,在 Python 3 上,您现在sep
可以str.split
通过关键字传递给。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句