>>> print(len.__doc__)
len(module, object)
Return the number of items of a sequence or mapping.
>>> len(os, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: len() takes exactly one argument (2 given)
注意文档字符串第一行中的两个参数。
什么时候将两个参数传递给 len
?文档字符串不正确吗?我正在使用 Python 3.4.0。
最佳答案
这是在 2014-04-18 here 提交的错误.它已在 3.4.1 中修复。
引用错误报告的原作者 Vedran Çačić 的话:
From recently, help(len) gives the wrong signature of len.
Help on built-in function len in module builtins:
len(...)
len(module, object)
^^^^^^^^
Return the number of items of a sequence or mapping.
关于python - len 的文档字符串中的 "module"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26609559/