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

python µÄtimeÄ£°å·­Ò뼰˵Ã÷

python µÄÄÚǶtimeÄ£°å·­Ò뼰˵Ã÷
Ò»¡¢¼ò½é
timeÄ£¿éÌṩ¸÷ÖÖ²Ù×÷ʱ¼äµÄº¯Êý
˵Ã÷£ºÒ»°ãÓÐÁ½ÖÖ±íʾʱ¼äµÄ·½Ê½:
µÚÒ»ÖÖÊÇʱ¼ä´ÁµÄ·½Ê½(Ïà¶ÔÓÚ1970.1.1 00:00:00ÒÔÃë¼ÆËãµÄÆ«ÒÆÁ¿),ʱ¼ä´ÁÊÇΩһµÄ
µÚ¶þÖÖÒÔÊý×éµÄÐÎʽ±íʾ¼´(struct_time),¹²ÓоŸöÔªËØ£¬·Ö±ð±íʾ£¬Í¬Ò»¸öʱ¼ä´ÁµÄstruct_time»áÒòÎªÊ±Çø²»Í¬¶ø²»Í¬
year (four digits, e.g. 1998)
month (1-12)
day (1-31)
hours (0-23)
minutes (0-59)
seconds (0-59)
weekday (0-6, Monday is 0)
Julian day (day in the year, 1-366)
DST (Daylight Savings Time) flag (-1, 0 or 1) ÊÇ·ñÊÇÏÄÁîʱ
If the DST flag is 0, the time is given in the regular time zone;
if it is 1, the time is given in the DST time zone;
if it is -1, mktime() should guess based on the date and time.
ÏÄÁîʱ½éÉÜ£ºhttp://baike.baidu.com/view/100246.htm
UTC½éÉÜ£ºhttp://wenda.tianya.cn/wenda/thread?tid=283921a9da7c5aef&clk=wttpcts
¶þ¡¢º¯Êý½éÉÜ
1.asctime()
asctime([tuple]) -> string
½«Ò»¸östruct_time(ĬÈÏΪµ±Ê±Ê±¼ä)£¬×ª»»³É×Ö·û´®
Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
When the time tuple is not present, current time as returned by localtime()
is used.
2.clock()
clock() -> floating point number
¸Ãº¯ÊýÓÐÁ½¸ö¹¦ÄÜ£¬
ÔÚµÚÒ»´Îµ÷ÓõÄʱºò£¬·µ»ØµÄÊdzÌÐòÔËÐеÄʵ¼Êʱ¼ä£»
ÒÔµÚ¶þ´ÎÖ®ºóµÄµ÷Ó㬷µ»ØµÄÊÇ×ÔµÚÒ»´Îµ÷Óúó,µ½Õâ´Îµ÷ÓõÄʱ¼ä¼ä¸ô
ʾÀý£º
view plaincopy to clipboardprint?
import time
if __name__ == '__main__':
time.sleep(1)
print "clock1:%s" % time.clock()
time.sleep(1)
print "clock2:%s" % time.clock()
time.sleep(1)
print "clock3:%s" % time.clock()
Êä³ö£º
clock1:3.35238137808e-006
clock2:1.00004944763
clock3:2.00012040636
ÆäÖеÚÒ»¸öclockÊä³öµÄÊdzÌÐòÔËÐÐʱ¼ä
µÚ¶þ¡¢Èý¸öclockÊä³öµÄ¶¼ÊÇÓëµÚÒ»¸öclockµÄʱ¼ä¼ä¸ô
3.sleep(...)
sleep(seconds)
Ïß³ÌÍÆ³ÙÖ¸¶¨µÄʱ¼äÔËÐУ¬¾­¹ý²âÊÔ£¬µ¥Î»ÎªÃ룬µ«ÊÇÔÚ°ïÖúÎĵµÖÐÓÐÒÔÏÂÕâÑùÒ»¾ä»°£¬Õâ¹ØÊÇ¿´²»¶®
“The argument may be a floating point number for subsecond precision.”
4.ctime(...)
ctime(seconds) -> string
½«Ò»¸öʱ¼ä´Á(ĬÈÏΪµ±Ç°Ê±¼ä)ת»»³ÉÒ»¸öʱ¼ä×Ö·û´®
ÀýÈ磺
time.ctim


Ïà¹ØÎĵµ£º

Python±ê×¼¿â randomÄ£¿é


Python±ê×¼¿â-randomÄ£¿é
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉú³ÉÆ÷. »ù±¾Ëæ»úÊýÉú³ÉÆ÷(»ùÓÚ Wichmann ºÍ Hill , 1982 µÄÊýѧÔËËãÀíÂÛ) ¿ÉÒÔͨ¹ýºÜ¶à·½·¨·ÃÎÊ, Èç Example 2-29 Ëùʾ. 2.17.0.1. Example 2-29. ʹÓà random Ä£¿é»ñµÃËæ»úÊý×Ö File: random-example-1.py import random for i i
¡¡¡¡
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉ ......

[python]PLYÄ£¿é Lex/YACCµÄpythonʵÏÖ

  PLYÄ£¿é ÊÇLex/YACCPython µÄʵÏÖ£¬¿ÉÒÔÓÃÀ´ÊµÏÖ´Ê·¨·ÖÎö/Óï·¨·ÖÎö£¬µ«ÈçºÎÓ㬻¹Ã»Ñо¿£¬ÒÔºóÓÐʱ¼äÔÙÑо¿°É£»
  Ö÷Ò³: http://www.dabeaz.com/ply/
  pycparserÄ£¿é ÊÇʹÓÃPLYÄ£¿é·ÖÎöcÓïÑÔÓï·¨µÄÄ£¿é£¬Ã»Ê²Ã´Îĵµ£¬µ«Ä£¿é×Ô´øÁËÀý×ӺͲâÊÔÓÃÀý¡£
   Ö÷Ò³: http://code.google.com/p/pycpa ......

ʹÓÃpdb½øÐÐpythonµÄµ÷ÊÔ

1 ÔÚÏëÒª²åÈë¶ÏµãµÄµØ·½²åÈë´úÂë
                import pdb
                pdb.set_trace()
2È»ºóʹÓÃÖ¸Áî½øÐÐdebug
²é¿´´úÂëÉÏÏÂÎÄ£¬l£¨Ð¡Ð´L£©
¼àÊÓ±äÁ¿ ......

python31ÓëC½»»¥

1.cµ÷ÓÃpython:
   ÊµÀý´úÂ룺
main.cµ÷ÓÃtest.pyµÄ
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//main.c
#include <windows.h>
......

Python MySqlDB Ôöɾ¸ÄÊý¾Ý¿â


ÏÂÔØ°²×°MySQLdb
http://sourceforge.net/projects/mysql-python/ ºÃÏñû¿´µ½windows°æ±¾for python2.6µÄÏÂÔØ£¬ÍøÉÏËÑË÷µ½Ò»¸ö
http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
°²×°ºóimport MySQLdb»á³öÏÖ DeprecationWarning: the sets module is deprecated ÕâÑùÒ»¸ö¾¯¸æ£¬googleÖ®
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ