开发者

Deleting dirs after finishing a command prompt

开发者 https://www.devze.com 2022-12-25 02:38 出处:网络
I have a python script that ends with running a program (iexpress.exe) in a dos prompt. The p开发者_Go百科rogram that runs in dos prompt, uses a dir called workdir.

I have a python script that ends with running a program (iexpress.exe) in a dos prompt.

The p开发者_Go百科rogram that runs in dos prompt, uses a dir called workdir. After the program has finished in the dos prompt I would like python to delete the dir. I have just made a simple solution of putting a delay of 30sec:

time.sleep(30)
removeall(workdir)
os.rmdir(workdir)

But how should I do it, if python should delete the dir right after the process has finished?


Make the python program call the exe and not fall off the end

ie call the exe using subprocess.Popen

The when the exe finishes you are still in python

0

精彩评论

暂无评论...
验证码 换一张
取 消