python做exe自动化传参时,出现当两个应用程序都没有控制台或控制台输入已从文件重定向时,无法读取键。
各位大神好,exe自动化输入参数时,端口输出Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.该如何解决,除了在打包是更改为windows程序,在python还有其他解决方法吗
import subprocess
import os,sys
import time
sir_util2_path = r'C:\Users\75622\Desktop\SendService.v1.3.1.1\SendService.ConsoleApp\SendService.ConsoleApp.exe'
sir_util2_path_1 = r'E:\KafkaMessagePulisher\KafkaMessagePublisher_selfdefine_interval_v1.0.0.4\KafkaMessagePublisher.exe'
def sir_to_geotiff():
param = ["22222", "33333333"]cmd = [sir_util2_path]
p = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
out, err = p.communicate(''.join(map(str, param)))
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, cmd, output=(out,err))
if name == "__main__":
try: sir_to_geotiff()
except subprocess.CalledProcessError as e:
err = e.output[0]
print(err)
以上是 python做exe自动化传参时,出现当两个应用程序都没有控制台或控制台输入已从文件重定向时,无法读取键。 的全部内容, 来源链接: utcz.com/p/938259.html