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

"""A parser for HTML and XHTML."""
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags a ......

ʹÓÃpdbµ÷ÊÔPython³ÌÐò

ʹÓÃpdbµ÷ÊÔPython³ÌÐò
 
±¾ÎÄÌÖÂÛÔÚûÓз½±ãµÄIDE¹¤¾ß¿ÉÓõÄÇé¿öÏ£¬Ê¹ÓÃpdbµ÷ÊÔpython³ÌÐò
 
Ô´ÂëÀý×Ó
ÀýÈ磬ÓÐÄ£Äâ˰ÊÕ¼ÆËãµÄ³ÌÐò£º
 
#!/usr/bin/python
def debug_demo(val):
                if val &l ......

python hidden features

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 continue

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

WebTrack ÔÚ python bottle frameworkÖеļòµ¥ÊµÏÖ

ÍøÂç³ô³æÒà¼´ÍøÂçÐű꣬ÊÇͨ¹ýijÖÖÊÖ¶ÎÒþʽ»ñÈ¡ÐÅÏ¢µÄµÄ·½·¨¡£
ÔÚbottle frameworkÖпÉÓÃÏÂÃæµÄ·½·¨ÊµÏÖ£º
Ê×ÏÈÔÚÄãÒªÓû§ä¯ÀÀÆ÷ÏÔʾµÄÒ³ÃætplÉÏǶÈëÒ»¸ö1*1ÏñËØµÄͼƬ£¬»ò¸üС¡£
Õâ¸öͼƬµØÖ·Ö¸ÏòÄã·þÎñÆ÷ÉÏij¸öÌØ¶¨Î»Öã¬Èçstatic/webtrack.png¡£
Óû§´ò¿ªÍøÒ³£¬¾Í»á·ÃÎÊÕâ¸öͼƬ£¨Í¨¹ýä¯ÀÀÆ÷Èçhttp://abc.abc.com/st ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ