Python 内省:函数参数的描述

发布于 2024-09-12 21:36:13 字数 123 浏览 0 评论 0原文

是否有一个类似于 dir() 的模块工具可以告诉我给定函数采用哪些参数?例如,我想做类似 dir(os.rename) 的事情,并让它告诉我记录了哪些参数,这样我就可以避免在线检查文档,而只使用 Python 脚本接口来做到这一点。

Is there is a tool similar to dir() for modules that will tell me what parameters a given function takes? For instance, I would like to do something like dir(os.rename) and have it tell me what parameters are documented so that I can avoid checking the documentation online, and instead use only the Python scripting interface to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦境 2024-09-19 21:36:13

我意识到您对 help(thing)thing.__doc__ 更感兴趣,但是如果您尝试进行编程内省(而不是人类可读的文档)要了解如何调用函数,您可以使用 inspect 模块,正如这个问题。

I realize that you're more interested in help(thing) or thing.__doc__, but if you're trying to do programmatic introspection (instead of human-readable documentation) to find out about calling a function, then you can use the inspect module, as discussed in this question.

我为君王 2024-09-19 21:36:13

help(thing) 漂亮地打印模块、方法等中的所有文档字符串......

help(thing) pretty prints all the docstrings that are in the module, method, whatever ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文