0

我正在使用此代码来启动批处理文件,但是

import os
os.startfile("C:\Documents and Settings\Zha\Desktop\Strings\strings.exe ")

当您从 cmd 打开时,strings.exe 运行批处理命令,如下所示:

strings -q "C:\Documents and Settings\Zha\Desktop\folder\*"

我需要从 python 运行它。解决这个问题的可能方法?

4

1 回答 1

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()
于 2014-06-10T12:46:20.000 回答