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

python socket server 并发(转)

import SocketServer, time, select, sys
from threading import Thread
COMMAND_HELLO = 1
COMMAND_QUIT = 2
# The SimpleRequestHandler class uses this to parse command lines.
class SimpleCommandProcessor:
    def __init__(self):
        pass
    def process(self, line, request):
        """Process a command"""
        args = line.split(' ')
        command = args[0].lower()
        args = args[1:]
        if command == 'hello':
            request.send('HELLO TO YOU TO!\n\r')
            return COMMAND_HELLO
        elif command == 'quit':
            request.send('OK, SEE YOU LATER\n\r')
            return COMMAND_QUIT
        else:
            request.send('Unknown command: "%s"\n\r' % command)
# SimpleServer extends the TCPServer, using the threading mix in
# to create a new thread for every request.
class SimpleServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
    # This means the main server will not do the equivalent of a
    # pthread_join() on the new threads. With this set, Ctrl-C will
    # kill the server reliably.
    daemon_threads = True
    # By setting this we allow the server to re-bind to the address by
    # setting SO_REUSEADDR, meaning you don't have to wait for
    # timeouts when you kill the server and the sockets don't get
 


相关文档:

Pamie模块详解 python操作ie浏览器

from http://blog.alexa-pro.cn/?p=315
此文档使用平台为 cPAMIE Build 2.0,和之前的版本有明显的差别,具体可直接看cPAMIE.py 源码
下面是一些常用的方法
ie.navigate('http://blog.alexa.cn') 用来访问一个链接。
ie.linkClick('linkname') 打开这个页面中的一个连接 参数: name或 id
ie.textBoxSet('labels','python ......

对Python进程进行全解析

下面对Python进程进行深入而仔细的学习,首先先让大家了解下什么是Python进程,以及在对Python进程进行处理时注意的相关问题,接下来,就由我给大家进行介绍学习,仅供大家学习。
不过,虽然进程可在单独的内存空间中执行,但除非这些Python进程在单独的处理器上执行,否则,实际并不是“同时”运行的。是由操作 ......

python 2.4与2.5中字符串与datetime转换的区别

python 2.4中datetime有strftime方法而无strptime方法
而python2.5中这两个方法均有,而我的开发环境正好是python 2.5,而运行环境则是python 2.4
开发环境下调试好的程序,在服务器上就不run。查了一下python的官方文档
,斜体写着:New
in version 2.5.
不兼容的代码如下:
Python语言
:
test_strptime.py
res ......

常用的python模块

from link http://www.tt010.net/cms/show_article/1057.html 发表评论 Post by : BossAdmin @[2009-12-12 17:11:20] views:115 adodb:我们领导推荐的数据库连接组件 bsddb3:BerkeleyDB的连接组件 Cheetah-1.0:我比较喜欢这个版本的cheetah cherrypy:一个WEB framework ctypes:用来调用动态链接库 DBUtils:数 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号