小编hxy*_*yhi的帖子

子进程标准输出到文件,缺少新行

我正在调用一个子进程,我希望将子进程输出写入一个已经打开的文件。我正在使用以下代码:

f1=open('solve.out','w') 
#beginning of the programm writes to this file
f_err = open('mor.err', "w")
arguments=[file.exe,arg1,arg2,...]
p=subprocess.Popen(arguments,stdout=f1, stderr=f_err)
p.wait()
f1.close()
f_err.close()
Run Code Online (Sandbox Code Playgroud)

这很好用,因为我从程序中的 .exe 获得实时输出。但是,输出都写在一行中。作为独立的,输出显示新行。

我尝试了 Universal_newlines 或 p.communicate() 没有成功。

编辑 1:windows10 Python 版本 2.7.13

编辑 2:十六进制文件 在此处输入图片说明

python subprocess popen

5
推荐指数
1
解决办法
1267
查看次数

调试时出错“插件是用不同版本的包构建的”失败

我构建了我的 .so 文件:

go build -buildmode=plugin -o test.so
Run Code Online (Sandbox Code Playgroud)

并使用 Goland 运行调试,然后出现错误:

Error running agent: could not initialize input inputs.plugin_input: plugin.Open("./plugins_lib/test1"): plugin was built with a different version of package runtime/internal/sys
Run Code Online (Sandbox Code Playgroud)

但是我可以在我的终端中构建我的主程序,它会运行良好。

plugins go goland

3
推荐指数
1
解决办法
162
查看次数

标签 统计

go ×1

goland ×1

plugins ×1

popen ×1

python ×1

subprocess ×1