[英]How to STOP python to complete execution on one operation and then start other process
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()
#The above structure is just an example, If you see in the for loop the fun1() and fun2() #calls happened simultaneously #But how can somebody first execute fun1() completely including the closure of command window #and then only move to calling fun2() in python. #上面的结构只是一个例子,如果你在for循环中看到fun1()和fun2() #calls同时发生#但是有人怎么能先完全执行fun1()包括关闭命令window #然后才移动在 python 中调用 fun2()。
#Kindly guide me on this.. #请在这方面指导我..
#Thank you. #谢谢。
Please avoid running scripts that way.请避免以这种方式运行脚本。 Also do not name variables like dir.
也不要命名变量,如 dir。 It helps a lot to get an editor which does some linting
获得一个做一些 linting 的编辑器有很大帮助
Just an example.只是一个例子。 Still it would be better to know what you try to achieve?
还是知道你想达到什么目标会更好?
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.