所以我在写一个程序,为另一个程序创建输入,然后对另一个程序创建的输出做一些处理。你知道吗
现在我想用Popen来打开这个程序并用这个程序运行一个脚本。我已经有了一个在windows上运行的版本,但是我想在Mac上也执行这个版本,这就开始出现问题了。你知道吗
在Mac上,它只启动一个带有所需程序的终端,而不执行其他操作。没有错误消息,我不知道我需要在我的命令中更改什么,所以它确实做了一些事情,而不仅仅是用程序打开一个终端并忽略我的脚本。你知道吗
# This function calls polymake to execute a script with two input parameters
console_object = subprocess.Popen(['/Applications/polymake.app/Contents/MacOS/polymake', '--script', script_filename, vertex_filename, poly_filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = console_object.communicate()
if stderr != None:
print(stderr)
raise SystemExit(1) # One should not do this in a function
if stdout != None:
string = str(stdout).replace('\\n', '\n')[1:]
if equalities:
string = string.replace(">=", "=")
print(string)
if equalities:
file = open(console_filename, 'a')
else:
file = open(console_filename, 'w')
file.write(string[1:-1])
file.close()
print("\nThis output was written into %s" % console_filename)
目前没有回答
相关问题 更多 >
编程相关推荐