我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
当前回答
python -V
http://docs.python.org/using/cmdline.html#generic-options
——version也可以工作(在2.5版本中引入)
其他回答
python -V
http://docs.python.org/using/cmdline.html#generic-options
——version也可以工作(在2.5版本中引入)
要在Jupyter笔记本中检查Python版本,您可以使用:
from platform import python_version
print(python_version())
获取版本号,如下:
3.7.3
or:
import sys
print(sys.version)
为了获得更多的信息,如
3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)]
or:
sys.version_info
要获得大版本、小版本和微版本,如
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
在命令提示符中输入Windows中python的位置可能会告诉你安装了多个不同版本的python的位置,假设它们已经添加到你的路径中。
在命令提示符中输入python -V应该会显示版本。
打开一个命令提示窗口(按Windows + R,键入cmd,并按Enter)。
类型python.exe
Use
python -V
or
python --version
注意:请注意python -V命令中的“V”是大写V。python -V(小“V”)将以verbose模式启动python。