python -V>> logfile.txt使这项工作需要什么?

时间:2015-11-02 18:20:51

标签: python

此命令无法按预期工作:

$ python -V >> logfile.txt

python版本显示在屏幕上,但不会在日志文件中结束,需要什么才能将它放入日志文件中?

2 个答案:

答案 0 :(得分:4)

$ python -V 2>> logfile.txt

python -V写入stderr而不是stdout,这就是为什么你必须用你的追加运算符附加2。

答案 1 :(得分:1)

-V输出转到stderr,所以你需要像这样重定向它:

python -V 2>> logfile.txt