每天某一時間段執行指令碼
阿新 • • 發佈:2018-11-09
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()