我正在使用此代码启动批处理文件,但
import os
os.startfile("C:\Documents and Settings\Zha\Desktop\Strings\strings.exe ")
strings.exe从cmd打开时运行批处理命令,如下所示:
strings -q "C:\Documents and Settings\Zha\Desktop\folder\*"
我需要从python运行它。可能的方法来解决这个问题?
答案 0 :(得分:0)
from subprocess import Popen, PIPE
handle = Popen(['strings', '-q', 'C:\\Documents and Settings\\Zha\\Desktop\\folder\\*'], stdout=PIPE)
while handle.poll() is None:
print(handle.stdout.readline())
handle.stdout.close()