为什么许多Python内置函数没有代码中的文档?
1 个回答
7
因为你使用的开发环境有点问题。
你提到的例子,dict#update
,其实Python本身提供了很好的内置帮助,但是你的开发环境没有显示出来。
$ python
Python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help({}.update)
Help on built-in function update:
update(...) method of builtins.dict instance
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
>>>