2013年10月29日

Python Cookbook学习记录 ch3_3/4_2013/10/29

摘要: 3.3 计算日期之间的时段给定两个日期,需要计算两个日期之间隔了几周感觉没有必要使用文中提到的dateutil模块,自己写了一段:>>> def totaltimer(times): td = datetime.timedelta(0) duration = sum([datetime.timedelta(minutes=x,seconds=y) for x,y in times],td) allseconds = duration.seconds print "The duration is "+str(int(allseconds/60))+" 阅读全文

posted @ 2013-10-29 22:20 七海之风 阅读(159) 评论(0) 推荐(0)

Python Cookbook学习记录 ch3_1/2_2013/10/29

摘要: 3.1计算昨天和明天的日期可以使用datetimie的timedelta方法来表示时间差>>> import datetime>>> today = datetime.date.today()>>> yesteday = today - datetime.timedelta(days=1)>>> tomorrow = today + datetime.timedelta(days=1)>>> print today,yesteday,tomorrow2013-10-29 2013-10-28 2013-1 阅读全文

posted @ 2013-10-29 21:28 七海之风 阅读(160) 评论(0) 推荐(0)

导航