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
 
Ïà¹ØÎĵµ£º
ʹÓÃpdbµ÷ÊÔPython³ÌÐò
±¾ÎÄÌÖÂÛÔÚûÓз½±ãµÄIDE¹¤¾ß¿ÉÓõÄÇé¿öÏ£¬Ê¹ÓÃpdbµ÷ÊÔpython³ÌÐò
Ô´ÂëÀý×Ó
ÀýÈ磬ÓÐÄ£Äâ˰ÊÕ¼ÆËãµÄ³ÌÐò£º
#!/usr/bin/python
def debug_demo(val):
if val &l ......
python 2.4ÖÐdatetimeÓÐstrftime·½·¨¶øÎÞstrptime·½·¨
¶øpython2.5ÖÐÕâÁ½¸ö·½·¨¾ùÓУ¬¶øÎҵĿª·¢»·¾³ÕýºÃÊÇpython 2.5£¬¶øÔËÐл·¾³ÔòÊÇpython 2.4
¿ª·¢»·¾³Ïµ÷ÊԺõijÌÐò£¬ÔÚ·þÎñÆ÷ÉϾͲ»run¡£²éÁËÒ»ÏÂpythonµÄ¹Ù·½Îĵµ
£¬Ð±Ìåд×Å£ºNew
in version 2.5.
²»¼æÈݵĴúÂëÈçÏ£º
PythonÓïÑÔ
:
test_strptime.py
res ......
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£ºÊý ......
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£ºÊý ......
1.º¯Êý
º¯Êýͨ¹ýdef¹Ø¼ü×Ö¶¨Òå¡£def¹Ø¼ü×Öºó¸úÒ»¸öº¯ÊýµÄ ±êʶ·û
Ãû³Æ£¬È»ºó¸úÒ»¶ÔÔ²À¨ºÅ¡£Ô²À¨ºÅÖ®ÖпÉÒÔ°üÀ¨Ò»Ð©±äÁ¿Ãû£¬¸ÃÐÐÒÔðºÅ½áβ¡£½ÓÏÂÀ´ÊÇÒ»¿éÓï¾ä£¬ËüÃÇÊǺ¯ÊýÌå¡£º¯ÊýÒ²ÓÐÐβκÍʵ²Î£¬ÓëC++Ψһ²»Ò»ÑùµÄÊÇÐββ»Ð´ÀàÐͶøÒÑ£¬Ö±½Óд±äÁ¿Ãû¡£
2.globalÓï¾ä
Èç¹ûÄãÏëҪΪһ¸ö¶¨ÒåÔÚº¯ÊýÍâµÄ±äÁ¿¸³Öµ£¬ÄÇÃ´Ä ......