Python的time模块的函数真周到。
import time;print " Return the current time in seconds since the Epoch.", time.time()print "年",time.localtime(time.time()).tm_yearprint "月",time.localtime(time.time()).tm_monprint "日",time.localtime(time.time()).tm_mdayprint "时:",time.localtime(time.time()).tm_hourprint "分:",time.localtime(time.time()).tm_minprint "秒:",time.localtime(time.time()).tm_secprint "周几:",time.localtime(time.time()).tm_wdayprint "一年的第几天:",time.localtime(time.time()).tm_ydayprint "是否夏令时:",time.localtime(time.time()).tm_isdstprint "现在开始收录数据",time.asctime( time.localtime(time.time()) )
运行结果:
Return the current time in seconds since the Epoch. 1420039481.4年 2014月 12日 31时: 23分: 24秒: 41周几: 2一年的第几天: 365是否夏令时: 0现在开始收录数据 Wed Dec 31 23:24:41 2014