阅读第三方模块的Python文档

4 投票
2 回答
3132 浏览
提问于 2025-04-15 20:23

我最近下载了IMDbpy这个模块。

import imdb
help(imdb)

但是我没有看到完整的文档。我必须要做

im = imdb.IMDb()
help(im)

才能查看可用的方法。我不太喜欢这个控制台界面。有没有更好的方式来查看文档呢?我想要的是关于imdb模块的所有文档都在一页上。

2 个回答

1

IPython中,你可以这样做:

[1]: import os
[2]: os?

< get the full documentation here >

# or you could do it on specific functions 
[3]: os.uname
<built-in function>



[4]: os.uname?

< get the full documentation here >


# Incase of modules written in python, you could inspect source code by doing
[5]: import string
[6]: string??

< hows the source code of the module >

[7]: string.upper??

< shows the source code of the function >
10

使用 pydoc

pydoc -w imdb

这会在同一个文件夹里生成一个名为 imdb.html 的文件。


pydoc -p 9090 这个命令会在9090端口启动一个HTTP服务器,你可以通过 http://localhost:9090/ 来浏览所有的文档。

撰写回答