聚烯烃八大维度执行脚本调试
This commit is contained in:
parent
29f73bba1a
commit
5b8b84f215
50
聚烯烃八大维度预测任务.py
Normal file
50
聚烯烃八大维度预测任务.py
Normal file
@ -0,0 +1,50 @@
|
||||
# 这是原油日度,周度,月度的预测,脚本
|
||||
# 遍历时间,跳过周六日,每日7点开始预测
|
||||
|
||||
import datetime
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
def run_predictions(target_date):
|
||||
"""执行三个预测脚本"""
|
||||
scripts = [
|
||||
"main_juxiting.py",
|
||||
"main_juxiting_zhoudu.py",
|
||||
"main_juxiting_yuedu.py"
|
||||
]
|
||||
|
||||
# 依次执行每个脚本
|
||||
for script in scripts:
|
||||
command = [r"C:\Users\Hello\.conda\envs\predict\python", script]
|
||||
subprocess.run(command, check=True)
|
||||
|
||||
|
||||
def is_weekday(date):
|
||||
"""判断是否为工作日(周一到周五)"""
|
||||
return date.weekday() < 5 # 0-4 为周一到周五
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# start_date = datetime.date(2025, 3, 13)
|
||||
# 开始时间取当前时间
|
||||
start_date = datetime.date.today()
|
||||
# end_date = datetime.date(2100, 12, 31)
|
||||
|
||||
current_date = start_date
|
||||
# while current_date <= end_date:
|
||||
# if is_weekday(current_date):
|
||||
# # 等待到目标日期的7点
|
||||
# target_time = datetime.datetime.combine(
|
||||
# current_date, datetime.time(13, 15))
|
||||
# while datetime.datetime.now() < target_time:
|
||||
# time.sleep(60) # 每分钟检查一次
|
||||
# print(f"等待到 {target_time} 开始执行任务")
|
||||
|
||||
# print(f"开始执行 {current_date} 的预测任务")
|
||||
# run_predictions(current_date)
|
||||
|
||||
# current_date += datetime.timedelta(days=1)
|
||||
|
||||
print(f"开始执行 {current_date} 的预测任务")
|
||||
run_predictions(current_date)
|
Loading…
Reference in New Issue
Block a user