1- Python Manuals
自帶CHM格式的Python Manuals存放在\Python<x.x>\Doc\目錄下。
可以在IDLE界面下按F1鍵或點擊help選項下Python Docs標簽打開;也可以在通過“開始 ---》python x.x ---》Python Manuals”打開。
2- Module Docs
包含了python中所有內置的和已經安裝的第三方Modules文檔信息
通過“開始 ---》python x.x ---》Module Docs”打開,出現pydoc程序界面,可以在搜索框直接查找需要的內容。
也可以點擊“open browser”建立本地臨時的web server,瀏覽網頁版的文檔信息。需要關閉時,點擊“quit serving”即可。
利用pydoc手工在指定端口打開web documentation server
"python -m pydoc -p 6789" (表示打開pydoc模塊來查看python文檔,並在6789端口上啟動web server)
然后訪問http://localhost:6789/,可以看到所有已經安裝的Modules文檔信息。需要關閉時,按“ctrl+c”可以終止命令或者關閉命令界面即可。
利用pydoc在終端下查看文檔信息
在命令行執行“python -m pydoc 函數名或模塊名”,可以看到自動生成的文檔信息,按q鍵退出。
例如:查看os模塊文檔"python -m pydoc os"
例如:在當前目錄生成dir函數的HTML文檔"python -m pydoc -w dir"
在Linux下同樣適用pydoc方式查看文檔。
詳細信息請查看:https://docs.python.org/3/library/pydoc.html
3- help()和dir()
help([object])
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
- 查看對象信息:help([object])
- 查看所有的keyword:help("keywords")
- 查看所有的modules:help("modules")
- 查看常見的topics: help("topics")
- 查看模塊,例如:help("sys")
- 查看數據類型,例如: help("list")
- 查看數據類型的成員方法,例如: help("list.append")
對於已定義或引入的對象,help([object])查詢不使用單引號和雙引號。對於未引入的模塊等對象,要使用單引號或雙引號。
dir([object])
Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.
查看當前屬性及方法:dir()
查看對象的屬性及方法:>dir([object])
dir([object]) 查詢不使用單引號和雙引號。
注意:
help()函數多用來查看對象的詳細說明,按q鍵退出。dir()函數多用來查看對象的屬性方法,輸出的是列表。
使用help()和dir()之前,確定查詢的對象已被定義或引入,否則會報錯:“NameError: name is not defined”。
dir(__builtins__) # 查看BIF(built-in functions)信息 help(input) # 參看input()函數的幫助信息
4- 在線文檔
官方文檔(https://docs.python.org/)是最具權威性質的說明和解釋,利用搜索功能(https://docs.python.org/3/search.html)可以快速獲取相關信息;
官網中文文檔:https://docs.python.org/zh-cn/
其他文檔:
- Python3.6中文: https://www.rddoc.com/doc/Python/3.6.0/zh/
- Python2.7中文:https://yiyibooks.cn/yy/python_278/index.html
- Python相關中文手冊:http://docs.pythontab.com/
5- Q&A
6- 搜索與請教
Google、百度、必應、牛人等等
7- Python第三方庫
- 使用PyPI搜索功能:https://pypi.org/
- Awesome Python:https://awesome-python.com/ (中文:https://github.com/jobbole/awesome-python-cn)
- Unofficial Windows Binaries for Python Extension Packages:http://www.lfd.uci.edu/~gohlke/pythonlibs