简体   繁体   English

如何将 python --version stdout 保存到文本文件?

[英]How to save python --version stdout to a text file?

I have tried the command below in both windows and mac:我在 windows 和 mac 中都尝试了以下命令:

python --version > file.txt

which will create a text file but the file it creates is empty.这将创建一个文本文件,但它创建的文件是空的。

python --version outputs to stderr not stdout so to capture it to file use this command: python --version输出到stderr而不是stdout ,因此要将其捕获到文件中,请使用以下命令:

python --version 2>file.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM