我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?

我在考虑升级到最新版本的Python。


当前回答

当我打开Python(命令行)时,它告诉我的第一件事是版本。

其他回答

当我打开Python(命令行)时,它告诉我的第一件事是版本。

python -V

http://docs.python.org/using/cmdline.html#generic-options

——version也可以工作(在2.5版本中引入)

在带有Python 3.9.1的Windows 10上,使用命令行:

    py -V

Python 3.9.1

    py --version

Python 3.9.1

    py -VV

Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit 
(AMD64)]

Python 2.5 +:

python --version

Python 2.4 -:

python -c 'import sys; print(sys.version)'

在命令提示符中键入:

python -V

如果你有pyenv

pyenv versions