Python Version
To get version of the current Python running in your system, we can use sys module. import sys module and read the sys.version property.
The sys.version property returns a string value with the version, and addition information like build version, and compiler used.
We can also read sys.version_info property to get a tuple containing the version’s major, minor, micro, release level, and serial.
Program
In the following program, we get the version of current Python, and print it to console.
Output
3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Now, let us use sys.version_info to get the version of Python we are using.
Output
sys.version_info(major=3, minor=10, micro=8, releaselevel='final', serial=0)
Summary
In this tutorial of Python Examples, we learned how to get the version of the current Python running in your system, with examples.
⫷ Previous Topic Python - Check if a given character is alphabet or not