加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
accwait.py 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
zero205 提交于 2021-03-27 01:35 . 搬运hajiuhajiu大佬时间延迟脚本
import time
import datetime
import logging
import sys
import random
padding = 1 # 提前时间
interval = 1 # 区间
minute = 59
if len(sys.argv) >= 2:
padding = float(sys.argv[1])
if len(sys.argv) >= 3:
interval = float(sys.argv[2])
if len(sys.argv) >= 4:
minute = int(sys.argv[3])
if padding == 0 or interval == 0:
second_setting = 0
ms_setting = 0
else:
start_time = 60 - padding - 0.5*interval
second_setting = int(start_time)
ms_setting = int((start_time - second_setting)*10**6)
target_time = datetime.datetime.now()
if target_time.minute > minute:
target_time = target_time.replace(hour=target_time.hour+1,minute=minute, second=second_setting, microsecond=ms_setting)
else:
target_time = target_time.replace(minute=minute, second=second_setting, microsecond=ms_setting)
i=0
while datetime.datetime.now() < target_time:
i += 1
if i % 300 == 0:
logging.warn(f'{datetime.datetime.now()}未到{target_time}点')
time.sleep(0.01)
time.sleep(random.random()*interval)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化