码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-11-04 23:37:25      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:example   file   int   详解   logs   ``   包含   模块   使用   

==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 模块详解

标签:example   file   int   详解   logs   ``   包含   模块   使用   

原文地址:http://www.cnblogs.com/xuchunlin/p/7784790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!