我正在使用subprocess.call
以这种方式用参数启动我的exe文件:
def run_file(self, file_path):
subprocess.call([r'c:\file.exe', self.server_ip_address, file_path])
这很好但现在我想等到我的return code
。
所以我尝试使用这种方法:
def run_file(self, file_path):
process = subprocess.call([r'c:\file.exe', self.server_ip_address, file_path])
process.wait()
print(process.returncode)
得到这个error
:
process.wait() AttributeError: 'int' object has no attribute 'wait'
使用subprocess.run
而不是subprocess.call
。它阻塞所以不需要wait
。
https://docs.python.org/fr/3/library/subprocess.html