我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
当前回答
简而言之:
在命令提示符中输入python
只需打开命令提示符(Win + R)并键入cmd,然后在命令提示符中输入python将为您提供有关版本的所有必要信息:
其他回答
python -V
http://docs.python.org/using/cmdline.html#generic-options
——version也可以工作(在2.5版本中引入)
只需创建一个以.py结尾的文件,并将下面的代码粘贴进去并运行它。
#!/usr/bin/python3.6
import platform
import sys
def linux_dist():
try:
return platform.linux_distribution()
except:
return "N/A"
print("""Python version: %s
dist: %s
linux_distribution: %s
system: %s
machine: %s
platform: %s
uname: %s
version: %s
""" % (
sys.version.split('\n'),
str(platform.dist()),
linux_dist(),
platform.system(),
platform.machine(),
platform.platform(),
platform.uname(),
platform.version(),
))
当系统中安装了多个Python解释器版本时,执行以下命令。
在Linux操作系统中,在终端中运行:
ll /usr/bin/python*
在Windows操作系统中,在命令提示符中运行:
dir %LOCALAPPDATA%\Programs\Python
对于最新版本,请使用下面的python版本命令
py -V
在命令提示符中输入Windows中python的位置可能会告诉你安装了多个不同版本的python的位置,假设它们已经添加到你的路径中。
在命令提示符中输入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.