1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

python --versionの出力は、python3.4からstdoutに出力されるようなっていた

Last updated at Posted at 2021-12-18

少しハマったのでメモです

python --versionの出力は、python3.4からstdoutに出力されるようなっていた

検証コード

test.py
import subprocess
ret = subprocess.run("python --version", shell=True, stdout=subprocess.PIPE , stderr=subprocess.PIPE ,encoding="utf-8")
print(ret)
python2.7の場合
python3 test.py 
CompletedProcess(args='python --version', returncode=0, stdout='', stderr='Python 2.7.17\n')
python3.7の場合
$ python3 test.py
CompletedProcess(args='python --version', returncode=0, stdout='Python 3.7.1\n', stderr='')

以下のリリースノートにpython3.4からstdoutに出力されるようになったと書いていた。

[view Doc/whatsnew/3.4.rst]

  • The python command and most stdlib scripts (as well as :mod:argparse) now
    output --version information to stdout instead of stderr (for
    issue list see :ref:other-improvements-3.4 above).

参考

view Doc/whatsnew/3.4.rst
changeset 89325:fc089cf0cf32
Why does python print version info to stderr?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?