
python
朱乐乐在路上
Smile as always
展开
-
python中os.system()的返回值
最近遇到os.system()执行系统命令的情况,上网搜集了一下资料,整理如下,以备不时之需,同时也希望能帮到某些人。 一、python中的 os.system(cmd)的返回值与linux命令返回值(具体参见本文附加内容)的关系 大家都习惯用os.systemv()函数执行linux命令,该函数的返回值十进制数(分别对应一个16位的二进制数)。该函数的返回值与 linux命令返回转载 2015-01-27 16:56:03 · 31614 阅读 · 1 评论 -
Python模块学习 ---- subprocess 创建子进程
最近,我们老大要我写一个守护者程序,对服务器进程进行守护。如果服务器不幸挂掉了,守护者能即时的重启应用程序。上网Google了一下,发现Python有很几个模块都可以创建进程。最终我选择使用subprocess模块,因为在Python手册中有这样一段话: This module intends to replace several other, older modules and fun转载 2015-01-27 21:19:22 · 709 阅读 · 0 评论 -
python连续处理两行数据
最近需要处理一个文件中的所有连续行的数据内容 import os import linecache #f = open('myout') count = len(open('myout').readlines()) #last_pos = f.tell() # get to know the current position in the file #f.seek(last_pos)原创 2014-12-18 12:50:53 · 13855 阅读 · 0 评论 -
python 读取文件的最后一行
with open(fname, 'rb') as fh: first = next(fh) offs = -100 while True: fh.seek(offs, 2) lines = fh.readlines() if len(lines)>1: last = lines[-1]原创 2014-12-18 08:40:02 · 10384 阅读 · 0 评论 -
windows python install pygtk
windows上安装gtk是一个老大难问题,特别是windows 64 下面转载一个文章,立斩所有麻烦 http://digitalpbk.blogspot.com/2012/03/installing-pygtk-pypango-and-pycairo-on.html To install pygtk, pypango and pycairo on Windows,转载 2015-07-07 10:42:57 · 1884 阅读 · 0 评论