【发布时间】:2016-08-31 08:43:48
【问题描述】:
我想在 computerinfo 文件中自动记录我的 python 版本。不过
python2 -V >> myfile
只打印到控制台而不是myfile。如何将输出保存到文件中?
奇怪的是,对于 python3 -- python3 -V >> myfile -- 这符合我的预期。
我在 Ubuntu 16.04 上使用 bash shell。
【问题讨论】:
-
你需要重定向stderr,像这样:
python2 -V 2>> myfile
标签: python bash file-io output