我想在关闭子进程后继续使用命令。我有以下代码,但是fsutil
没有执行。我该怎么做?你知道吗
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
至少,我认为您需要将代码更改为这样:
从documentation for ^{} :
可以用} 中有此警告
p.wait()
替换p.communicate()
,但是documentation for ^{相关问题 更多 >
编程相关推荐