如何让我的 write() 函数接受我的 stdout = subprocess.PIPE 输出?我不断收到类型错误问题。这是我的代码:with open("logger.txt","w") as fobj: baby = subprocess.Popen('bash arguments', stdout = subprocess.PIPE, shell = True) fobj.write(baby.communicate())我得到类型错误我试过这个,没有错误,但文件总是空的with open("logger.txt","w") as fobj: baby = subprocess.Popen('bash arguments', stdout = subprocess.PIPE, shell = True) baby.communicate()谁能帮我?谢谢
1 回答
慕容708150
TA贡献1831条经验 获得超4个赞
如果您只想将脚本的输出写入fobj,
with open("logger.txt","wb") as fobj:
subprocess.check_call('bash arguments', stdout=fobj, shell=True)
添加回答
举报
0/150
提交
取消