from datetime import datetime, timedelta import time def doFunc(): print ‘do function...‘ def doFirst(): curTime=datetime.now() desTime=curTime.replace(hour=21,minute=22,second=0,microsecond=0) delta=desTime-curTime skipSeconds = (24*60*60+delta.total_seconds())%(24*60*60) print "must sleep %d seconds" % skipSeconds return skipSeconds while True: doFunc() time.sleep(doFirst())
原文:http://www.cnblogs.com/wood9291/p/5107472.html