gpt4 book ai didi

python - 显示子进程的控制台输出

转载 作者:太空宇宙 更新时间:2023-11-04 01:17:19 25 4
gpt4 key购买 nike

<分区>

我想知道,如何获得在 Python 脚本中调用的子进程的输出?

from sys import argv
from os.path import exists
from subprocess import call

script, source, target = argv

print "Copying from %s to %s" % (source, target)

indata = open(source).read()

if exists(target):
out_file = open(target, 'w')
out_file.write(indata)
call(["cat", target]) #how can I get text printed on console by cat?
print "OK."
out_file.close()

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com