windows中一个python脚本中打开一个新的cmd终端执行另一个脚本

import os
from threading import Thread
from multiprocessing import Process
import subprocess


def func():
    # os.system("python ./test2.py")
    # os.system("gnome-terminal -e 'bash -c \"ls; exec bash\"'")
    # subprocess.call_in_new_window('python ./test2.py', shell=True)
    # subprocess.call(['gnome-terminal', '-x', 'python ./test2.py'])
    subprocess.call('python ./test2.py', creationflags=subprocess.CREATE_NEW_CONSOLE)


if __name__ == '__main__':
    # t = Thread(target=func)
    # t.start()
    p = Process(target=func)
    p.start()
发布了79 篇原创文章 · 获赞 9 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/s_daqing/article/details/104621198