易截截图软件、单文件、免安装、纯绿色、仅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: python写的一个简单网络词典

闲来无事, 玩玩python...
是采用有道翻译, 然后抓取网页的.
import re, urllib
url="http://dict.youdao.com/search?le=eng&q="
print ("input q to exit")
while 1:
word = raw_input(">>>")
if word=="q":
exit()
else:
word = word.replace(' ', '+')
url += word
u ......

写了几个有关operaminimod的python小程序

写了几个有关operaminimod的python小程序
firefox->opm书签转换
import re
def pipeiwangzhi(a):
    s=[]
    pp= re.compile(r'<DT><A HREF="(.*)" ADD_DATE=(.*>)(.*)</A>')
    m=pp.search(a)
    s1=[]
  ......

Python: python的简单表达式计算器

这是一个简单的表达式计算器, 不太懂用Tkinter写GUI, 参考了别人的代码
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pa ......

Python and RRD

RRD是Round Robin Database的意思,RRDTool是用来管理RRD的一个工具。RRDTool的主页在这里,Wikipedia的页面在这里。RRD其实就是一个时序数据库,使用一个固定大小的环型buffer,适用于存储一些统计性的信息,如CPU负载呀,气温变化呀。我为什么要说这个东西呢,因为XenServer里的性能统计是用的RRD,你可以访问诸如http:// ......

scite python API

'''gen_python_api.py generates a python.api file for SciTE
The generated api file includes
*) all Python keywords
*) all builtin functions
*) all module attributes
Module functions are represented by their docstring if available,
otherwise by the function definition from the source file. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号