易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : Python

Python监视进程


由subprocess创建一个进程,然后进行监视
每一秒钟查看一次,如果正在运行,打印pid和running,如果已停止,,继续执行任务并打印Termined
shell和stdout均设置为False
也许这对做病毒的守护进程很好
#!/usr/bin/env python
import subprocess , sys , time
p=subprocess.Popen(['ping','127.0.0.1','-n','10'], shell=False,stdout=False)
while 1:
    time.sleep(1)
    ret=subprocess.Popen.poll(p)
    if ret is None:
        print p.pid,"running"
    else:
        print "Termined!"
        p=subprocess.Popen(['ping','127.0.0.1','-n','10'], shell=False,stdout=False)
......

eat python 003

Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at the
beginning of the file.
a Open for writing. The file is created if it does not exist. The stream
is positioned at the end of the file.
a+ Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file.
======================================================
In Python: http://docs.python.org/library/functions.html#open
Modes 'r+'
, 'w+'
and 'a+'
open the file for updating (note that
'w+'
truncates the file). Append 'b'
to the mode to open the f ......

opencv python cool

当年做毕业论文的时候openCV就像是我的瑞士军刀,太有感情了。如今用了一年多的python,发现openCV也有python版本了,真是太酷了!当然python在处理图像时还可以用其它库例如PIL(Python Imaging Library ),一种轻量级的图像库。目前openCV1.0版本对应的python版本为2.5,openCV2.0对应python 2.6。
附录:
1. 一篇介绍图像处理库是 PIL(Python Image Library)的blog:
http://blog.csdn.net/lanphaday/archive/2007/10/28/1852726.aspx
2. openCV简介
OpenCV全程open source computer vision library.是Intel开发的一个计算机视觉库,包含了多种计算机图形图像处理的库,目前版本为V1.0,可以在商业和研究领域免费实用。
主要用于处理
图像处理
计算机视觉
模式识别
物体识别(人脸识别,Object识别)
运动跟踪
3. 在python中使用OpenCV
在python中使用OpenCV
http://www.opencv.org.cn/index.php/%E5%9C%A8python%E4%B8%AD%E4%BD%BF%E7%94%A8OpenCV
安装python2.5
到以下地址下载, 然后默认安装.
http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi
安装OpenCV
下载OpenCV, 安装后将对应的bin目录添加到PATH变量.
http://www.opencv.org.cn ......

Eclipse+PyDev = Python编辑器,

http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-pydev/连接这个网址,不会让你失望的。
PyDev 简介
2003年7月16日,以 Fabio Zadrozny 为首的三人开发小组在全球最大的开放源代码软件开发平台和仓库 SourceForge 上注册了一款新的项目,该项目实现了一个功能强大的 Eclipse插件,用户可以完全利用 Eclipse 来进行 Python 应用程序的开发和调试。这个能够将 Eclipse当作 Python IDE 的项目就是 PyDev。
PyDev 插件的出现方便了众多的 Python 开发人员,它提供了一些很好的功能,如:语法错误提示、源代码编辑助手、Quick Outline、Globals Browser、Hierarchy View、运行和调试等等。基于 Eclipse 平台,拥有诸多强大的功能,同时也非常易于使用,PyDev 的这些特性使得它越来越受到人们的关注。
如今,该项目还在不断地推进新的发布版本,目前最新的版本是2008年10月3日发布的1.3.22。本文接下来将介绍 PyDev 的安装配置方法,并在此基础上详细介绍如何使用 PyDev把 Eclipse 当作 Python IDE 进行Python的开发和调试。 ......

python 俄罗斯方块

这个算是C++嵌入python吧,利用python实现显示和事件处理,C++实现逻辑
以后有时间也会反过来试试:) 
import pygame
import sys
import os
import ctypes
def cur_file_dir():
#获取脚本路径
path = sys.path[0]
#判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径
if os.path.isdir(path):
return path
elif os.path.isfile(path):
return os.path.dirname(path)

#call dll
path = cur_file_dir()
print path
rblogic = ctypes.CDLL(path+r'\rblogic.dll')
#pygame init
pygame.init()
screen = pygame.display.set_mode((640,500),0,32)
pygame.display.set_caption('RussiaBoxGame!_by warmtrue')
rblogic.InitGame()
moveflag = 0
font = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 40)
fontsmall = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 15)
fontless = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 15)
#gam ......

Python 的C语言扩展

操作系统:linux debian 4.0, python版本2.5
s1:安装python2.5-dev。因为Python.h是在dev包中才有。
test@debian:~/test_python_c$ aptitude search python2.5-dev
p python2.5-dev - Header files and a static library for Python.
test@debian:~/test_python_c$ sudo aptitude install python2.5-dev
...
test@debian:~/test_python_c$ aptitude search python2.5-dev
i python2.5-dev - Header files and a static library for Python.
s2:准备测试文件——C语言函数
//filename:example.c
int fact(int n)
{
if(n<=1)
return 1;
else
return n*fact(n-1);
}

s3: 编写封装接口
//filename: wrap.c
#include <Python.h>
PyObject* wrap_fact(PyObject* self, PyObject* args)
{
int n, result;
if (! PyArg_ParseTuple(args, "i:fact", &n))
return NULL;
result = fact(n);
return Py_BuildValue("i", result);
}
static PyMethodDef exampleMethods[] =
{
{"fact", wrap_fact, METH_VARARGS, "Caculate N!"},
{NULL, NULL}
};
void initexam ......

Python 的C语言扩展

操作系统:linux debian 4.0, python版本2.5
s1:安装python2.5-dev。因为Python.h是在dev包中才有。
test@debian:~/test_python_c$ aptitude search python2.5-dev
p python2.5-dev - Header files and a static library for Python.
test@debian:~/test_python_c$ sudo aptitude install python2.5-dev
...
test@debian:~/test_python_c$ aptitude search python2.5-dev
i python2.5-dev - Header files and a static library for Python.
s2:准备测试文件——C语言函数
//filename:example.c
int fact(int n)
{
if(n<=1)
return 1;
else
return n*fact(n-1);
}

s3: 编写封装接口
//filename: wrap.c
#include <Python.h>
PyObject* wrap_fact(PyObject* self, PyObject* args)
{
int n, result;
if (! PyArg_ParseTuple(args, "i:fact", &n))
return NULL;
result = fact(n);
return Py_BuildValue("i", result);
}
static PyMethodDef exampleMethods[] =
{
{"fact", wrap_fact, METH_VARARGS, "Caculate N!"},
{NULL, NULL}
};
void initexam ......
总记录数:695; 总页数:116; 每页6 条; 首页 上一页 [76] [77] [78] [79] 80 [81] [82] [83] [84] [85]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号