import subprocess import time while True: # 在此处编写要执行的任务,例如打印系统负载 cmd = "uptime" result = subprocess.check_output(cmd, shell=True) print(result.decode("utf-8")) # 暂停1秒,然后继续执行 time.sleep(1)