每天某一时间段运行脚本

import os
import datetime
import time

def get_list():
    all_filename=os.listdir(os.getcwd())
    return all_filename

def get_file():
    all_file=[]
    for i in  get_list():
        if i=='Run_Test.py':
            continue
        if i.endswith('.py'):
            all_file.append(i)
    return all_file

def run_test():
    for i in range(len(get_file())):
        print(i+1,'测试接口:',get_file()[i])
        os.system('python '+get_file()[i])
        print('\n')

def main(h=10,m=0):
    while True:
        now=datetime.datetime.now()
        # print(now.hour,now.minute)
        if now.hour==h and now.minute==m:
            break
    run_test()

if __name__=='__main__':
    # run_test()
    while True:
        main()

猜你喜欢

转载自blog.csdn.net/lssrain/article/details/81064031