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
 
Ïà¹ØÎĵµ£º
from http://stackoverflow.com/questions/101268/hidden-features-of-python
http://www.okpython.com/bbs/thread-3434-1-1.html
http://www.okpython.com/bbs/thread-3436-1-2.html
http://www.okpython.com/bbs/thread-3437-1-2.html
http://www.okpython.com/bbs/thread-3438-1-1.html
http://www.okpython.com/bb ......
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 ......
°²×°ÎļþÏÂÔØ:
MySQL-python-1.2.2.win32-py2.6.exe
https://docs.google.com/leaf?id=0B-C0ABoe2nuLMDlhZjI5OTQtMWNmYy00ZTNlLWJjNzMtYTc2Y2EzMGFjMzcy&hl=zh_CN
ÐèÒªµÄ¶îÍâdllÎļþÏÂÔØ:
libmmd.dll
https://docs.google.com/leaf?id=0B-C0ABoe2nuLZTk2M2RiZTAtYzY5My00NzNjLTg5ZWEtMzRkZGEyYjUxNThh&hl=zh_C ......
ãÂã¶®¶®µÄ°²×°ÁËPython£¬²»Îª±ðµÄ£¬Ö»Îª¸Ïµãʱ÷Ö£¬ÒòΪ¿´¼ûºÜ¶àÓÎÏ·¹«Ë¾¶¼ÒªÇó»áÒ»µãPython»òÕßLUA£¬Ã»°ì·¨£¬»¹ÊǶàѧһµãºÃ£¬·´ÕýÏÐ×ÅÒ²ÊÇÏÐ×Å¡£×Ô¼ºÄ¿Ç°²»¶®LINUX£¬ËùÒÔÔÝÇÒÓÃÓÃWINDOWSϵİɡ£
ÈëÃÅ»¹ºÃÈëÊÖ£¬²»ÊǾÞÄÑ£¬Ö¸³ö¼¸µãÓÐÒâ˼µÄ£º
ûÓлù±¾ÀàÐÍÁË£¬µ±ÎÒ°²cÓïÑÔÓ﷨дint xÊ ......