简体   繁体   English

检查运行给定脚本的 python 版本

[英]Check python version running a given script

Imagine I have installed two versions of python and I am running a .py file.想象一下,我已经安装了两个版本的 python 并且我正在运行一个.py文件。 I would like to know which of the two versions is running the script and eventually be able to change it.我想知道这两个版本中的哪一个正在运行脚本并最终能够对其进行更改。 The problem is that I do not know where to start from in order to get the information even though it shouldn't be that taugh.问题是我不知道从哪里开始以获得信息,即使它不应该那么教。

Could you please give me a little hint about it?你能给我一点提示吗?

there's a few different ways to do this from within a script, some good info here: link在脚本中有几种不同的方法可以做到这一点,这里有一些很好的信息:链接

simplest is probably one of these最简单的可能是其中之一

import sys
import platform
sys.version
sys.version_info
platform.python_version()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM