![](/img/trans.png)
[英]How to run executable with file input/output in Python using subprocess?
[英]Python run an executable file in python using subprocess windows 10
我正在嘗試運行與我的 python 文件位於同一文件夾中的 massdns.exe
subprocess.run("dir", shell=True)
輸出
Volume in drive C has no label.
Volume Serial Number is A6AB-C832
Directory of C:\Users\Owner\Desktop\folder1\folder2\massdns
02/02/2020 07:59 PM 251,991 massdns.exe
如您所見,它在同一個文件夾中。
當我嘗試執行subprocess.run(".\\massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)
它什么也不做。 而在命令行窗口或 powershell 窗口中,它會按預期運行程序。
我嘗試過的事情 subprocess.check_output("massdns.exe -r lists/resolvers.txt -t AAAA -w results.txtgenerated_domains.txt", shell=True)
subprocess.run(".\\massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)
當我這樣做時
subprocess.check_output("massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)
我收到這個錯誤
subprocess.CalledProcessError: Command 'massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt' returned non-zero exit status 3221225781.
我想出了我的問題,如果你和我不在同一個房間里,這真的很難回答。 我正在使用 pycharm 並將 massdns.exe 文件移動到另一個文件夾中(盡管我試圖在 python 中執行它的同一個文件夾)並且我沒有關閉我的 pycharm 的命令行,我想它以某種方式弄亂了它,我全部關閉 pycharm 和 ta-da 它起作用了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.