# -*- coding:utf-8 -*- import time from datetime import datetime from jdlogger import logger from config import global_config class Timer(object): def __init__(self, sleep_interval=0.5): # '2018-09-28 22:45:50.000' self.buy_time = datetime.strptime(global_config.getRaw('config','buy_time'), "%Y-%m-%d %H:%M:%S.%f") self.sleep_interval = sleep_interval def start(self): logger.info('æ£å¨çå¾ å°è¾¾è®¾å®æ¶é´:%s' % self.buy_time) now_time = datetime.now while True: if now_time() >= self.buy_time: logger.info('æ¶é´å°è¾¾ï¼å¼å§æ§è¡â¦â¦') break else: time.sleep(self.sleep_interval)