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

Python¼¸ÖÖ²¢·¢ÊµÏÖ·½°¸µÄÐÔÄܱȽÏ

 
#!/Library/Frameworks/Python.framework/Versions/2.5/bin/python
# encoding: utf-8
import sys, time
import thread
 
SLEEP_TIME = 0.0001
 
def run_benchmark(n, m):
    # print(">> Python 2.5.1, stackless 3.1b3 here (N=%d, M=%d)!\n" % (n, m))
    locks = [thread.allocate_lock() for i in xrange(n)]
    firstP = cin = []
    cin_lock_id = 0
    for s in xrange(1, n):
        seqn = s
        cout = []
        cout_lock_id = s
        # print("*> s = %d" % (seqn, ))
        thread.start_new_thread(loop, (seqn, locks, cin, cin_lock_id, cout, cout_lock_id))
        cin = cout
        cin_lock_id = cout_lock_id
    else:
        seqn = s+1
        # print("$> s = %d" % (seqn, ))
        thread.start_new_thread(mloop, (seqn, locks, cin, cin_lock_id))
    for r in xrange(m-1, -1, -1):
        # print("+ sending Msg#  %d" % r)
        lock = locks[0]
        lock.acquire()
        firstP.append(r)
        lock.release()
        time.sleep(SLEEP_TIME)
    try:
        while True:
            time.sleep(SLEEP_TIME)
    except:
        pass
def loop(s, locks, cin, cin_lock_id, cout, cout_lock_id):
    while True:
        lock = locks[cin_lock_id]
        lock.acquire()
        if len(cin) > 0:
            r = cin.pop(0)
            lock.release()
        else:
      &n


Ïà¹ØÎĵµ£º

ʹÓÃPythonÓïÑÔÉè¼Æ»ùÓÚHTMLµÄCÓïÑÔÓï·¨¼ÓÁÁÏÔʾ³ÌÐò

2005-2006ѧÄêµÚ1ѧÆÚ
±à Òë Ô­ Àí 
¿Î ³Ì Éè ¼Æ ±¨ ¸æ
°à¼¶   02¼Æ(¶þ)   
ѧºÅ     19     
ÐÕÃû     ÁõÏþÃ÷     
³É¼¨           
Ö¸µ¼½Ìʦ   ¬³¯»Ô   
Ò»¡¢   Éè¼ÆÄ¿µÄ
¼ÓÉî¶Ô±àÒ ......

´©Ô½Python Challenge£¨0

Ò»¸öÓÐȤµÄÍøÕ¾£º
http://www.pythonchallenge.com/
¼¯ÓéÀÖÓëѧϰÓÚÒ»Ì壬ÔÚ¿ª¶¯ÄԽ¹ØµÄ¹ý³ÌÖУ¬²»µ«À©Õ¹ÁË˼ά£¬»¹¶ÔPython¼ÓÉîÁËÀí½â¡£
Ò»¹²33¹Ø£¬Ã¿´³¹ýÒ»¹Ø¶¼¿ÉÒÔÔÚÌáʾϲ鿴×÷Õ߸ø³öµÄSolution¡£
µÚ0¹Ø£¨Ö¸µ¼¹Ø£©£º
    ³öÏÖÒ»·ù»­Ã棬ÉÏÃæд×Å2**38£¬½ÌÄãÈçºÎ½øÈëÏÂÒ»¹Ø¡£  
&nb ......

Installing Python °²×°Python


   
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python °²×°Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
 
D ......

pythonÖеÄroundÄÚ½¨º¯Êý

 ½ñÌìÓÖɨÁËÒ»±éÊý×ÖÕâÒ»ÕÂ.. ¿´µ½ÁËround()º¯Êý, ÊÇÔÚpythonºËÐıà³Ì˼ÏëµÄ5.6.2½ÚµÄĩβ, Ô­ÎÄÈçÏÂ:
round(flt, ndig=0) ½ÓÊÜÒ»¸ö¸¡µãÊý flt ²¢¶ÔÆäËÄÉáÎåÈ룬±£´æ ndigλСÊý¡£
Èô²»Ìṩndig ²ÎÊý£¬ÔòĬÈÏСÊýµãºó0λ¡£
round()½öÓÃÓÚ¸¡µãÊý¡££¨ÒëÕß×¢£ºÕûÊýÒ²¿ÉÒÔ£¬ ²»¹ý²¢Ã»ÓÐʲô
ʵ¼ÊÒâÒ壩
Æäʵ, ×ö¸ö浄 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ