如何抓取python运行之后的结果

2025-03-09 11:57:40
推荐回答(1个)
回答1:

data = os.popen('./test.sh').read()

【 在 pengsen (相濡以沫不若相忘于江湖) 的大作中提到: 】
: 比如我自己写了一个脚本,test.sh,这个脚本会向STDOUT写一个字符串,我现在这样
: os.system('./test.sh')
: 之后想把执行结果保存到一个变量里,应该怎么做呢?
: ...................

--
He said all were knights.
You say all are managers.
Then they fight and die
and program and survive.
But they lost the holy land
without angel's crying.