
1.7 在线帮助和相关资源
1.7.1 Python交互式帮助系统
在Python中包含了许多内置函数,可以实现交互式帮助,直接输入help()函数可以进入交互式帮助系统;输入help(object)可以获取关于object对象的帮助信息。
【例1.22】 使用Python交互式帮助系统示例。
(1)进入交互式帮助系统。输入help(),然后按Enter键,如图1-21所示。

图1-21 进入交互式帮助系统
(2)显示安装的所有模块。输入modules,然后按Enter键,如图1-22所示。
(3)显示与random相关的模块。输入modules random,然后按Enter键,如图1-23所示。
(4)显示random模块的帮助信息。输入random,然后按Enter键,如图1-24所示。用户可以通过空格键或者Enter键查看下一页帮助信息,通过Q或者q键结束random帮助信息的显示,返回help交互式帮助系统界面。

图1-22 显示安装的所有模块

图1-23 显示与random相关的模块

图1-24 显示random模块的帮助信息
(5)显示random模块的random函数的信息。输入random.random,然后按Enter键,如图1-25所示。

图1-25 显示random模块的random函数的信息
(6)退出帮助系统。输入quit,然后按Enter键。
【例1.23】 使用Python内置函数获取帮助信息。
(1)查看Python内置对象列表。输入下列命令:

(2)查看float的信息。输入下列命令:

(3)查看内置类float的帮助信息。输入如图1-26所示的命令。

图1-26 查看内置类float的帮助信息
1.7.2 Python文档
Python文档提供了有关Python语言及标准模块的详细参考信息,是学习和使用Python语言编程的不可或缺的工具。
【例1.24】 使用Python文档。
(1)打开Python文档。单击“开始”按钮,选择“所有应用”|Python 3.7|Python 3.7 Manuals(64-bit)命令(用户也可以在IDLE环境下按F1键),打开Python文档,如图1-27所示。

图1-27 打开Python文档
(2)浏览random模块的帮助信息。在左侧的目录树中依次展开,浏览random模块的帮助信息,如图1-28所示。

图1-28 浏览random模块的帮助信息
(3)查找有关math的帮助信息。在左侧单击“搜索”选项卡,输入math,然后按Enter键,接着在左侧的目录树中双击查找有关math的帮助信息,如图1-29所示。

图1-29 查找有关math模块的帮助信息
1.7.3 Python官网
Python官网的地址为https://www.python.org/,如图1-30所示,用户可以从中下载各种版本的Python程序或者查看帮助文档等。

图1-30 Python官网
1.7.4 Python扩展库索引
PyPI(Python Package Index)是Python官方的扩展库索引,所有人都可以下载第三方库或上传自己开发的库到PyPI。PyPI推荐使用pip包管理器来下载第三方库。
PyPI官网的地址为https://pypi.python.org/,如图1-31所示。

图1-31 PyPI官网