我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
我必须在Windows服务器上运行Python脚本。我怎么知道我用的是哪个版本的Python,这真的很重要吗?
我在考虑升级到最新版本的Python。
当前回答
如果你安装了Python,那么检查版本号最简单的方法是在命令提示符中输入“Python”。它将显示版本号,以及它是运行在32位还是64位以及其他一些信息。对于某些应用程序,您可能希望使用最新版本,但有时不需要。这取决于您想要安装或使用什么包。
其他回答
在Python IDE中,只需复制并粘贴以下代码并运行它(版本将出现在输出区域):
import sys
print(sys.version)
Use
python -V
or
python --version
注意:请注意python -V命令中的“V”是大写V。python -V(小“V”)将以verbose模式启动python。
主要是使用命令:
python -version
Or
python -V
只需创建一个以.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
对我来说,打开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.