简体   繁体   中英

How to save python --version stdout to a text file?

I have tried the command below in both windows and 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 2>file.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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