Python 文件后台运行

import time
import os
from multiprocessing import Process

def demo():
    time.sleep(20)

def main():
    Process(target=demo).start()
    os.system("kill -KILL {}".format(os.getpid(), os.getpid()))
posted @ 2020-08-20 10:23  twfb  阅读(285)  评论(0编辑  收藏  举报