我想在关闭子进程后继续执行命令。我有以下代码,但不执行fsutil
。我该怎么做?关闭python命令子进程
import os
from subprocess import Popen, PIPE, STDOUT
os.system('mkdir c:\\temp\\vhd')
p = Popen(["diskpart"], stdin=PIPE, stdout=PIPE)
p.stdin.write("create vdisk file=c:\\temp\\vhd\\test.vhd maximum=2000 type=expandable\n")
p.stdin.write("attach vdisk\n")
p.stdin.write("create partition primary size=10\n")
p.stdin.write("format fs=ntfs quick\n")
p.stdin.write("assign letter=r\n")
p.stdin.write("exit\n")
p.stdout.close
os.system('fsutil file createnew r:\dummy.txt 6553600') #this doesn´t get executed
请不要再使用'os.system()'。这是非常老式的,建议不推荐使用很长时间。 –
你如何不建议在我的代码中包含fsutil行? –
不应该是'p.stdout.close()'?我想你错过了一些括号。 –