eat python 002
ĿǰΪֹ£¬¾ÝÎÒËùÖª£¬ÔÚpythonÖжÔÏó³Ö¾Ã»¯ÓÐÒÔϼ¸ÖÖ·½·¨£º
1. ʹÓÃ(dbhash/bsddb, dbm, gdbm, dumbdbm µÈ£©ÒÔ¼°ËüÃǵÄ"¹ÜÀíÆ÷"( anydbm )¡£Ö»ÌṩÁË Python ×Ö
·û´®µÄÓÀ¾ÃÐÔ´¢´æ. Ìṩһ¸öÀàËÆ×ÖµäºÍÎļþµÄ¶ÔÏ󣬿ÉÒÔÍê³É×Ö·û´®µÄÓÀ¾ÃÐÔ´æ´¢¡£
2. ʹÓÃmarshalºÍpickleÀ´ÐòÁл¯python¶ÔÏ󣬲¢¾ß±¸´æ´¢µ½½éÖÊÉϵŦÄÜ¡£Á½ÕßµÄÇø±ðÔÚÓÚ£ºmarshalÖ»ÄÜ´¦Àí¼òµ¥µÄPython¶ÔÏ󣬰üÀ¨Êý×Ö¡¢ÐòÁС¢Ó³Éä¡¢ÒÔ¼°´úÂë¶ÔÏó£»¶øpickle»¹¿ÉÒÔ´¦ÀíµÝ¹é¶ÔÏ󣬱»²»Í¬µØ·½¶à´ÎÒýÓõĶÔÏó£¬ÒÔ¼°Óû§¶¨ÒåµÄÀàºÍʵÀý¡£ÆäÖУ¬pickleÓÐÒ»¸öCÓïÑÔʵÏֵİ汾——cPickle£¬¾ßÓиü¸ßµÄЧÂÊ£¬½¨ÒéʹÓÃcPickle¡£
3. ËäÈ»pickleÌṩ·Ç³£Ç¿´óµÄ¹¦ÄÜÁË£¬ÒѾ¿ÉÒÔÂú×ãÎÒÃǴ󲿷ֵÄÐèÇóÁË£¬µ«ÊÇ£¬ÈËÀàµÄÐèÇóÊÇÎÞÖ¹¾³µÄ£¬¹âÐòÁл¯²»Ðа¡£¬Ö»Óà pickle ²»Äܽâ¾öÃüÃûºÍ²éÕÒ pickle ÎļþÕâÑùµÄÎÊÌ⣬ҪÊÇ¿ÉÒÔ¶ÔÐòÁл¯µÄ¶ÔÏóÌṩ¹ÜÀí¹¦ÄÜ£¬Ö§³Ö²¢·¢·ÃÎʾͺÃÁË¡£Òò´Ë£¬ÈËÃÇ·¢Ã÷ÁËshelveÄ£¿é£¬ËüÊÇǰÁ½ÕßµÄ×ۺϡ£shelveÄ£¿éʹÓà anydbmÄ£¿éѰÕÒºÏÊʵÄDBMÄ£¿é£¬È»ºóʹÓÃcPickleÀ´Íê³É¶ÔÏó´æ´¢×ª»»¹ý³Ì¡£shelveÄ£¿éÔÊÐí¶ÔÊý¾Ý¿âÎļþ½øÐв¢·¢µÄ¶Á·ÃÎÊ£¬µ«²»ÔÊÐí¹²Ïí¶Á/д·ÃÎÊ¡£
4. »¹ÓÐÒ»ÖÖ·½°¸£¬ÊÇÔÚIBMµÄÍøÕ¾ÉÏ¿´µ½µÄ¡£ÄǾÍÊÇZODB[1]ÁË¡£ZODB±È¼òµ¥µÄ pickle Îļþ¸ü½¡×³ÒÔ¼°¸ü¾ßÓпÉÉìËõÐÔ¡£ZODBÊÇÒ»¸öÕë¶ÔPythonµÄZ¶ÔÏóÊý¾Ý¿â£¬ÊÇÒ»¸ö½¡×³µÄ¡¢¶àÓû§µÄºÍÃæÏò¶ÔÏóµÄÊý¾Ý¿âϵͳ£¬ËüÄܹ»´æ´¢ºÍ¹ÜÀíÈÎÒ⸴Ô Python ¶ÔÏ󣬲¢Ö§³ÖÊÂÎñ²Ù×÷ºÍ²¢·¢¿ØÖÆ¡£Æäʵ£¬ZODBÒ²ÒÀ¿¿Python µÄ±¾»úÐòÁл¯ÄÜÁ¦£¬¶øÇÒÒªÓÐЧµØÊ¹Óà ZODB£¬±ØÐë³ä·ÖÁ˽â pickle¡£
5. ×îºóÒ»Ö»ÖªµÀµÄ½â¾ö³Ö¾ÃÐÔÎÊÌâµÄ·½·¨ÊÇ Prevayler£¬PyPerSyst ½«Õû¸ö¶ÔÏóϵͳ±£´æÔÚÄÚ´æÖУ¬²¢Í¨¹ý²»Ê±µØ½«ÏµÍ³¿ìÕÕ pickle µ½´ÅÅÌÒÔ¼°Î¬»¤Ò»¸öÃüÁîÈÕÖ¾£¨Í¨¹ý´ËÈÕÖ¾¿ÉÒÔÖØÐÂÓ¦ÓÃ×îеĿìÕÕ£©À´ÌṩÔÖÄѻָ´¡£ËùÒÔ£¬¾¡¹ÜʹÓà PyPerSyst µÄÓ¦ÓóÌÐòÊܵ½¿ÉÓÃÄÚ´æµÄÏÞÖÆ£¬µ«ºÃ´¦ÊDZ¾»ú¶ÔÏóϵͳ¿ÉÒÔÍêȫװÈëµ½ÄÚ´æÖУ¬Òò¶øËٶȼ«¿ì£¬¶øÇÒʵÏÖÆðÀ´Òª±ÈÈç ZODB ÕâÑùµÄÊý¾Ý¿â¼òµ¥£¬ZODB ÔÊÐí¶ÔÏóµÄÊýÄ¿±ÈͬʱÔÚÄÜÄÚ´æÖÐËù±£³ÖµÄ¶ÔÏóÒª¶à¡£
±³¾°ÖªÊ¶£ºËü×î³õÊÇÓà Java ʵÏֵġ£ºóÀ´£¬Ò»Èº Python ³ÌÐòÔ±½« Prevayler ÒÆÖ²µ½ÁË Python ÉÏ£¬ÁíÆðÃûΪ PyPerSyst£¬ÓÉ SourceForge Íйܡ£Prevayler/PyPerSyst ¸ÅÄîÒ²Êǽ¨Á¢ÔÚ Java ºÍ Python ÓïÑԵı¾»úÐòÁл¯ÄÜÁ¦Ö®ÉÏ¡£
[1]: http://www.zope.org/Documentation/Articles/ZODB1
Ïà¹ØÎĵµ£º
½ñÌìÓöµ½Ò»¸öÒ»¸öÎÊÌ⣬Êǽ«×Ö·û´®ÀàÐ͵Äʱ¼äת»¯ÎªUTCʱ¼ä¡£ÀýÈçtime_str = "2009/11/09 12:23:23" ת»¯ÎªUTC intÐÍ¡£
ÕÒÁËһЩ×ÊÁÏ£¬·¢ÏÖtimeÄ£¿é¾ÍÄÜÍê³ÉÕâ¸öת»»¡£
import time
time_str = "2009/11/09 12:23:23"
time_s = time.strptime(time_str,"%Y/%m/%d %H:%M:%S")
utc_f = time.mktime(time_s)
utc_i = int ......
pythonÖйúÂÛ̳ http://www.okpython.com/bbs/index.php
¿ªÔ´ÉçÇø http://sourceforge.net/
python¹ÙÍø http://www.python.org/
pythonIDE BOAhttp://boa-constructor.sourceforge.net/
pythonIDE ´óÈ«http://www.oschina.net/project/tag/120
python×é¼þhttp://py.dw ......
Ò¹ÀïÓÃÍâ¹ÒÈÝÒ×±»²é£¬Òò´ËÏëÈòËÊìµÄʱ¼ä¼¯Öе½°×Ì죬ÿ´Î¶¼Òª¿ÚË㣬Âé·³£¬ÕýºÃ¸Õ¸ÕѧÁËwxPython£¬Ò»Ê±ÊÖÑ÷£¬À´×Ô¼ºÐ´¸ö°É¡£Ëä˵´¿Êô×ÔÓé×ÔÀÖ£¬µ«Ò²Ñ§µ½²»ÉÙ¶«Î÷¡£ÏÖ¼ÇÓÚÏ¡£
1. ¹ØÓÚPythonµÄGUIÉè¼Æ
Ò»Ö±ÒÔÀ´¶¼Ã»ÓÐÒ»¸ö×ã¹»ºÃµÄKiller IDE£¬ÕâÒ²¹Ö²»µÃ£¬Ã»ÓÐÒ»¸ö×㹻ǿ´óµÄºǫ́£¬ÒªÏë×ö³ÉÖØÁ¿¼¶µÄIDE̸ºÎÈÝÒ×£¨ÒªÊ ......
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))
lock ......