Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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
 


Ïà¹ØÎĵµ£º

Python´úÂë¼ÓÃÜ Ô´Âë±£»¤ pycÎļþ'×Ö½ÚÂë'

from   http://blog.alexa-pro.cn/?p=349
ÄÚÈݸÅÒª:Python´úÂë¼ÓÃÜ,Ô´Âë±£»¤,´úÂë±£»¤,pycÎļþ
------------------------------------------------
¹ØÓÚpython´úÂë±£»¤ÔÚÍøÉϺÃÏñһֱûÓкܺõĽéÉÜ,¿ÉÄܺÍPYTHONµÄÉè¼Æ³õÖÔ"¿ªÔ´"ÓйØ,µ«Ô½À´Ô½¶àµÄÐÖµÜдµÄ¼ÓÈëPYTHONÕóÓª,¿ª·¢¹¤¾ßÓÃ;¸÷Òì,ÔÚÉÌÒµÓ¦ÓÃÖдúÂë± ......

python self __init__

self
ÀàµÄ·½·¨ÓëÆÕͨµÄº¯ÊýÖ»ÓÐÒ»¸öÌØ±ðµÄÇø±ð——ËüÃDZØÐëÓÐÒ»¸ö¶îÍâµÄµÚÒ»¸ö²ÎÊýÃû³Æ£¬µ«ÊÇ
ÔÚµ÷ÓÃÕâ¸ö·½·¨µÄʱºòÄ㲻ΪÕâ¸ö²ÎÊý¸³Öµ£¬Python»áÌṩÕâ¸öÖµ¡£Õâ¸öÌØ±ðµÄ±äÁ¿Ö¸¶ÔÏó±¾
Éí£¬°´ÕÕ¹ßÀýËüµÄÃû³ÆÊÇself¡£
ÕâÒ²Òâζ×ÅÈç¹ûÄãÓÐÒ»¸ö²»ÐèÒª²ÎÊýµÄ·½·¨£¬Ä㻹ÊǵøøÕâ¸ö·½·¨¶¨ÒåÒ»¸öself²ÎÊý¡£
__init_ ......

°²×°mysqldb 1.2.2 for python 2.6

°²×°ÎļþÏÂÔØ:
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 continue

1.º¯Êý
º¯Êýͨ¹ýdef¹Ø¼ü×Ö¶¨Òå¡£def¹Ø¼ü×Öºó¸úÒ»¸öº¯ÊýµÄ ±êʶ·û
Ãû³Æ£¬È»ºó¸úÒ»¶ÔÔ²À¨ºÅ¡£Ô²À¨ºÅÖ®ÖпÉÒÔ°üÀ¨Ò»Ð©±äÁ¿Ãû£¬¸ÃÐÐÒÔðºÅ½áβ¡£½ÓÏÂÀ´ÊÇÒ»¿éÓï¾ä£¬ËüÃÇÊǺ¯ÊýÌå¡£º¯ÊýÒ²ÓÐÐβκÍʵ²Î£¬ÓëC++Ψһ²»Ò»ÑùµÄÊÇÐββ»Ð´ÀàÐͶøÒÑ£¬Ö±½Óд±äÁ¿Ãû¡£
2.globalÓï¾ä
Èç¹ûÄãÏëҪΪһ¸ö¶¨ÒåÔÚº¯ÊýÍâµÄ±äÁ¿¸³Öµ£¬ÄÇÃ´Ä ......

³õ̸PythonµÄ²»Í¬Ò»¡¾±Ê¼Ç£¬¹Ûºó¸Ð¡¿

    ãÂã¶®¶®µÄ°²×°ÁËPython£¬²»Îª±ðµÄ£¬Ö»Îª¸Ïµãʱ÷Ö£¬ÒòΪ¿´¼ûºÜ¶àÓÎÏ·¹«Ë¾¶¼ÒªÇó»áÒ»µãPython»òÕßLUA£¬Ã»°ì·¨£¬»¹ÊǶàѧһµãºÃ£¬·´ÕýÏÐ×ÅÒ²ÊÇÏÐ×Å¡£×Ô¼ºÄ¿Ç°²»¶®LINUX£¬ËùÒÔÔÝÇÒÓÃÓÃWINDOWSϵİɡ£
   ÈëÃÅ»¹ºÃÈëÊÖ£¬²»ÊǾÞÄÑ£¬Ö¸³ö¼¸µãÓÐÒâ˼µÄ£º
ûÓлù±¾ÀàÐÍÁË£¬µ±ÎÒ°²cÓïÑÔÓ﷨дint xÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ