如何停止python以完成一个操作的执行,然后启动另一个进程

如何停止python以完成一个操作的执行,然后启动另一个进程,python,Python,#上面的结构只是一个示例,如果您在for循环中看到fun1()和fun2()#调用同时发生 #但是,如何才能先完全执行fun1(),包括关闭命令窗口,然后在python中只调用fun2() #请在这方面指导我 #谢谢。请避免以这种方式运行脚本。也不要命名像dir这样的变量。 找到一个能做一些线头的编辑会有很大帮助 只是一个例子。不过,最好还是知道你想要实现什么 def fun1(): #something(opens a command window in a folder and ru

#上面的结构只是一个示例,如果您在for循环中看到fun1()和fun2()#调用同时发生 #但是,如何才能先完全执行fun1(),包括关闭命令窗口,然后在python中只调用fun2()

#请在这方面指导我


#谢谢。

请避免以这种方式运行脚本。也不要命名像dir这样的变量。 找到一个能做一些线头的编辑会有很大帮助

只是一个例子。不过,最好还是知道你想要实现什么

def fun1():
    #something(opens a command window in a folder and run something)
    os.system("start cmd /c omake clean ")
def fun2():
    #something(opens a command window again in the same folder and run something else)
    os.system("start cmd /c omake ")

for dir in list_of_dir:
    os.chdir(dir)
    fun1()
    fun2()

这可能取决于您的操作系统,但您可以搜索操作系统。wait()我使用的是windows OSos。wait()应该可以工作,但是从脚本开始批处理并不好,最好直接调用os.wait(“omake clean”):)omake做过什么
import os
from os import listdir
from os.path import isfile, join

def fun1():
    os.system("dir")
    print('fun1: done!')
    
    
def fun2():
    os.system("dir")
    print('fun1: done!')


path_folder = "c:/Windows"
file_names = [f for f in listdir(path_folder) if isfile(join(path_folder, f))]


for filen_name in file_names:
    os.chdir(path_folder)
    fun1()
    fun2()