zhangshijiezsj

1 在当前文件创建helloworld.py文件

import os
os.system(\'C:\python36\python.exe helloworld.py \') # 指定路径 执行helloworld.py 文件

  

 

 

2 周期性执行helloworld.py 文件

import time,os,sched
schedule = sched.scheduler(time.time,time.sleep)

def perform_command(cmd,inc):
  #在inc秒后再次运行自己,即周期运行
  schedule.enter(inc, 0, perform_command, (cmd, inc))
  
  os.system(cmd)
def timming_exe(cmd,inc=60):
  schedule.enter(inc,0,perform_command,(cmd,inc))
  schedule.run()#持续运行,直到计划时间队列变成空为止
print(\'show time after 2 seconds:\')
# timming_exe(\'echo %time%\',1)
timming_exe(\'C:\python36\python.exe helloworld.py\',2)

 执行效果

 

分类:

技术点:

相关文章:

  • 2021-12-13
  • 2021-11-21
  • 2021-12-12
  • 2022-01-04
  • 2021-11-16
  • 2021-11-05
  • 2021-11-20
  • 2021-11-16
猜你喜欢
  • 2021-11-05
  • 2021-12-12
  • 2021-11-06
  • 2021-11-16
  • 2021-11-05
  • 2021-08-25
  • 2021-05-25
相关资源
相似解决方案