python标准库介绍——34 commands 模块详解

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python标准库介绍——34 commands 模块详解相关的知识,希望对你有一定的参考价值。

==commands 模块==


(只用于 Unix) ``commands`` 模块包含一些用于执行外部命令的函数. 
[Example 3-7 #eg-3-7] 展示了这个模块.

====Example 3-7. 使用 commands 模块====[eg-3-7]

```
File: commands-example-1.py

import commands

stat, output = commands.getstatusoutput("ls -lR")

print "status", "=>", stat
print "output", "=>", len(output), "bytes"

*B*status => 0
output => 171046 bytes*b*
```

  

以上是关于python标准库介绍——34 commands 模块详解的主要内容,如果未能解决你的问题,请参考以下文章

Python 3.7.x 介绍-8 标准库 2

1Python标准库系列之模块介绍

Python标准库:1. 介绍

Python汇总篇,200+个Python标准库介绍(超全)

转:Python标准库(非常经典的各种模块介绍)

Python 3.7.x 介绍-7 标准库