Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python Ï̲߳Ù×÷

ÔÚpythonÖÐÈçºÎ´´½¨Ò»¸öÏ̶߳ÔÏó
Èç¹ûÄãÒª´´½¨Ò»¸öÏ̶߳ÔÏ󣬺ܼòµ¥£¬Ö»ÒªÄãµÄÀà¼Ì³Ðthreading.Thread£¬È»ºóÔÚ__init__ÀïÊ×Ïȵ÷ÓÃthreading.ThreadµÄ__init__·½·¨¼´¿É
import threading
class mythread(threading.Thread):
    def __init__(self, threadname):
        threading.Thread.__init__(self, name = threadname)
....
Õâ²Å½ö½öÊǸö¿ÕỊ̈߳¬Îҿɲ»ÊÇÒªËûÀ­¿Õ³µµÄ£¬Ëû¿ÉµÃ¸øÎҸɵãʵÔڻºÜ¼òµ¥£¬ÖØдÀàµÄrun()·½·¨¼´¿É£¬°ÑÄãÒªÔÚÏß³ÌÖ´ÐÐʱ×öµÄÊÂÇ鶼·Åµ½ÀïÃæ
import threading
import time
class mythread(threading.Thread):
    def __init__(...):
    ....
    def run(self):
        for i in range(10):
        print self.getName, i
        time.sleep(1)
ÒÔÉÏ´úÂëÎÒÃÇÈÃÕâ¸öÏß³ÌÔÚÖ´ÐÐÖ®ºóÿ¸ô1ÃëÊä³öÒ»´ÎÐÅÏ¢µ½ÆÁÄ»£¬10´Îºó½áÊø
getName()ÊÇthreading.ThreadÀàµÄÒ»¸ö·½·¨£¬ÓÃÀ´»ñµÃÕâ¸öÏ̶߳ÔÏóµÄname¡£»¹ÓÐÒ»¸ö·½·¨setName()µ±È»¾ÍÊÇÀ´ÉèÖÃÕâ¸öÏ̶߳ÔÏóµÄnameµÄÁË¡£
Èç¹ûÒª´´½¨Ò»¸öỊ̈߳¬Ê×ÏȾÍÒªÏÈ´´½¨Ò»¸öÏ̶߳ÔÏó
mythread1 = mythread('mythread 1')
Ò»¸öÏ̶߳ÔÏó±»´´½¨ºó£¬Ëû¾Í´¦ÓÚ“born”£¨µ®Éú״̬£©
ÈçºÎÈÃÕâ¸öÏ̶߳ÔÏó¿ªÊ¼ÔËÐÐÄØ?Ö»Òªµ÷ÓÃÏ̶߳ÔÏóµÄstart()·½·¨¼´¿É
mythread1.start()
ÏÖÔÚÏ߳̾ʹ¦ÓÚ“ready”״̬»òÕßÒ²³ÆΪ“runnable”״̬¡£
Ææ¹ÖÂ𣿲»ÊÇÒѾ­startÁËÂð£¿ÎªÊ²Ã´²»³ÆΪ“running”״̬ÄØ£¿ÆäʵÊÇÓÐÔ­ÒòµÄ¡£ÒòΪÎÒÃǵļÆËã»úÒ»°ãÊDz»¾ßÓÐÕæÕý²¢Ðд¦ÀíÄÜÁ¦µÄ¡£ÎÒÃÇËùνµÄ¶àÏß³ÌÖ»ÊÇ°Ñʱ¼ä·Ö³ÉƬ¶Î£¬È»ºó¸ôÒ»¸öʱ¼ä¶Î¾ÍÈÃÒ»¸öÏß³ÌÖ´ÐÐһϣ¬È»ºó½øÈë“sleeping ”״̬£¬È»ºó»½ÐÑÁíÒ»¸öÔÚ“sleeping”µÄỊ̈߳¬Èç´ËÑ­»·runnable->sleeping->runnable... £¬Ö»ÊÇÒòΪ¼ÆËã»úÖ´ÐÐËٶȺܿ죬¶øʱ¼äƬ¶Î¼ä¸ôºÜС£¬ÎÒÃǸÐÊܲ»µ½£¬ÒÔΪÊÇͬʱ½øÐеġ£ËùÒÔ˵һ¸öÏß³ÌÔÚstartÁËÖ®ºóÖ»ÊÇ´¦ÔÚÁË¿ÉÒÔÔËÐеÄ״̬£¬ËûʲôʱºòÔËÐл¹ÊÇÓÉϵͳÀ´½øÐе÷¶ÈµÄ¡£
ÄÇÒ»¸öÏß³Ìʲôʱºò»á“dead”ÄØ£¿Ò»°ãÀ´Ëµµ±Ï̶߳ÔÏóµÄrun·½·¨Ö´ÐнáÊø»òÕßÔÚÖ´ÐÐÖÐÅ׳öÒì³£µÄ»°£¬ÄÇôÕâ¸öÏ߳̾ͻá½áÊøÁË¡£ÏµÍ³»á


Ïà¹ØÎĵµ£º

python pyc

 Ê²Ã´ÊÇpycÎļþ
pycÊÇÒ»ÖÖ¶þ½øÖÆÎļþ£¬ÊÇÓÉpyÎļþ¾­¹ý±àÒëºó£¬Éú³ÉµÄÎļþ£¬ÊÇÒ»ÖÖbyte code£¬pyÎļþ±ä³ÉpycÎļþºó£¬¼ÓÔصÄËÙ¶ÈÓÐËùÌá¸ß£¬¶øÇÒpycÊÇÒ»ÖÖ¿çƽ̨µÄ×Ö½ÚÂ룬ÊÇÓÉpythonµÄÐéÄâ»úÀ´Ö´Ðеģ¬Õâ¸öÊÇÀàËÆÓÚJAVA»òÕß.NETµÄÐéÄâ»úµÄ¸ÅÄî¡£pycµÄÄÚÈÝ£¬ÊǸúpythonµÄ°æ±¾Ïà¹ØµÄ£¬²»Í¬°æ±¾±àÒëºóµÄpycÎļþÊDz»Í¬µÄ£¬2 ......

ÓÃpythonµÄcmdÄ£¿éдһ¸ö¼òµ¥µÄshell

 from cmd import *
class MyShell(Cmd):
    def preloop(self):
        print "print this line before entering the loop"
            
    def postloop(self):
&nb ......

Python , Delphi , Loki ÓÐȤµÄÀ´Ô´

 Python , Delphi , Loki Èý¸öµ¥´ÊÓÐȤµÄÀ´Ô´
Ðí¶à³ÌÐòÉè¼ÆÓïÑԺͿª·¢¹¤¾ßÒÔ¼°¿âµÄÃû×Ö¶¼À´Ô´ÓëÉñ»°£¬ÆÄÓÐÒâ˼£º
     °¢²¨ÂÞÊÇͬʱ³öÏÖÔÚÏ£À°ºÍÂÞÂíÉñ»°ÖеİÂÁÖÅÁ˹ʮ¶þ´óÉñÖ®Ò»¡£Ëû³ýÁËÓµÓÐÌ«ÑôÉñµÄÉí·Ö£¬Í¬Ê±»¹ÓÐÔ¤ÑÔ¡¢ÒÕÊõ¡¢Ò½ÊõÖ®ÉñµÄ³ÆºÅ¡£°¢²¨ÂÞÊÇÖæ˹ºÍÀÖ¶äµÄ¶ù×Ó£¬ºÍ°¢µÙÃÛ˹ÊÇË ......

Python¿ª·¢Activex×é¼þ

PythonÇ¿µÄ¹¦ÄܾÍÔÚÓÚËüÎÞËù²»ÄÜ¡£
ʹÓÃwin32comÄ£¿é¿ª·¢window ActiveXµÄʾÀý£º£¨Èç¹ûÄ㻹ûÓÐ×°win32comÄ£¿éµÄ»°£¬Çëµ½http://python.net/crew/skippy/win32/Downloads.htmlÏÂÔØ£©¡£
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
......

PythonÓÐÓõÄÄ£¿é

http://chardet.feedparser.org/  ×Ô¶¯¼ì²â±àÂë
http://effbot.org/zone/celementtree.htm  cElementTree
http://github.com/jaybaird/python-bloomfilter bloomfilter
http://docs.python.org/library/threading.html#threading.activeCount threading ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ