比如我们要知道我们现在安装过什么包。
当然我们也可以用 pip install 来安装我们需要的包。网上也可以下载到。
下面将对 IPython 和 Bash 做一个对比。 我们使用的是 IPython 没有的可以下载安装一个,或者用普通的Python的 >>>也可以。 输入 ipython开始使用

==================================================同样是输出一段文字Bash

IPython

我们看到几乎没有什么差别。仅仅是命令的不同==================================================查询目录内容Bash

IPython

结果一样,但是我们使用了 import 来导入一个叫 subprocess 的模块。其实有点像 shell 下的 source 。所谓模块就类似于一个盒子,盒子里放着各种素材,当我们需要某种素材的时候,我们找到相应的盒子,取出素材。加到我们的工程中。==================================================包装一个命令所谓包装一个命令,就是使用一个程序完成一系列的任务。形成一个功能。比如

我们通过使用一个Python程序实现了一个LINUX系统下面 ls -l的功能。结果为:

==================================================使用 Python 和 Shell 将两个功能各包装成一个命令所谓包装命令其实也是 Bash 和 Python 共有的。我们使用 Python 和 Bash 各包装一个复杂点的命令。显示系统信息。BASH

PYTHON

PYTHON 里完全可以不用将参数和命令分开写。以下写法也是可以的。subprocess.call("df -h", shell=True)注意 True 的 T 要大写。。。

我们在一个脚本里实现了2个查询功能。分别查询了内核版本和文件系统的利用率。结果一样

==================================================在IPython下的辅助功能。在IPython这个工具的帮助下,我们可以实现一些辅助查询的功能。比如:

我们导入 subprocess 模块后,仅输入 subprocess. 后面跟2下 tab 键 就可以查询到可用的对象。如果在对象后加一个 ? 就可以了解对象的功能。比如
