易截截图软件、单文件、免安装、纯绿色、仅160KB

python 执行系统命令比较

转载自:http://purpen.javaeye.com/blog/98095
python 执行系统命令比较
关键字: python os system 系统命令
在此比较一下两种方法执行系统命令的方法,以方便于日后运用:(
1. os.system()
system(command) -> exit_status  
      
Execute the command (a string) in a subshell.  
  
  
# 仅仅在一个子终端运行系统命令,而不能获取命令执行后的返回信息..  
 
>>> os.system('ls')  #如果再命令行下执行,结果直接打印出来
04101419778.CHM  bash     document   media     py-django  video  
11.wmv           books    downloads  Pictures  python  
all-20061022     Desktop  Examples   project   tools  
  
2.os.popen()
popen(command [, mode='r' [, bufsize]]) -> pipe  
      
Open a pipe to/from a command returning a file object.  
  
# 此种方法不但执行命令还返回执行后的信息对象   
 
>>>tmp = os.popen('ls *.py').readlines()  
  
>>>tmp  
Out[21]:   
['dump_db_pickle.py\n',  
 'dump_db_pickle_recs.py\n',  
 'dump_db_shelve.py\n',  
 'initdata.py\n',  
 '__init__.py\n',  
 'make_db_pickle.py\n',  
 'make_db_pickle_recs.py\n',  
 'make_db_shelve.py\n',  
 'peopleinteract_query.py\n',  
 'reader.py\n',  
 'testargv.py\n',&n


相关文档:

[Python module] queue

8.8. queue — A synchronized queue class¶
queue -- 一个同步队列类
The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implemen ......

python decorator

1.常用方法,不带参数
def decator(func):
    def inner_func(*args):
        args = (i * 2 for i in args)
        return func(*args)
    return inner_func
   
@decator
def add(a, ......

python decorator

1.常用方法,不带参数
def decator(func):
    def inner_func(*args):
        args = (i * 2 for i in args)
        return func(*args)
    return inner_func
   
@decator
def add(a, ......

Python发送天气预报信息到手机

writeblog.csdn.net writeblog.csdn.net/PostEdit.aspx
这个程序很早以前就写过了,而且是参考的别人的写,具体谁的发在哪里我都忘记了。这里就算是半原创了,如有侵权请及时通知改正。
因为从今天1月1号开始,Google上订阅的天气预报服务已经取消了,估计是Google被施加压力了。反正是收不到天气预报了。正好重拾以前 ......

Python 3 初探,第 1 部分: Python 3 的新特性

Python 3 是 Guido van Rossum 功能强大的通用编程语言的最新版本。它虽然打破了与 2.x 版本的向后兼容性,但却清理了某些语法方面的问题。本文是系列文章中的第一篇,介绍了影响该语言及向后兼容性的各种变化,并且还提供了新特性的几个例子。
Python 版本 3,也被称为 Python 3000 或 Py3K(仿效 Microsoft® Windows ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号