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

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


当前回答

在Windows操作系统下,在命令提示符中输入以下命令,验证命令的Python版本。

c:\> python -V
Python 2.7.16

c:\> py -2 -V
Python 2.7.16

c:\> py -3 -V
Python 3.7.3

此外,要查看每个Python版本的文件夹配置,请运行以下命令:

For Python 2, 'py -2 -m site'
For Python 3, 'py -3 -m site'

其他回答

python -V

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

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

在Python IDE中,只需复制并粘贴以下代码并运行它(版本将出现在输出区域):

import sys
print(sys.version)

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

我在Windows 10上安装了Python 3.7.0。

这是我在命令提示符和Git Bash中工作的方法:

使用实例运行Python并查看版本。

py

只检查您拥有的版本:

py --version

or

py -V    # Make sure it is a capital V

注意:python, python——version, python -V, python, python——version, python -V不适合我。

对我来说,打开CMD并运行

py

会显示一些东西

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.