Home >Backend Development >Python Tutorial >How to get the currently used Python version information? (code example)
This article mainly introduces how to obtain the current Python version. I hope it will be helpful to friends in need!
Version information:
A tuple containing the version number of the five components: major, minor, micro, releaselevel, and serial. All values except releaselevel are integers; release level is "alpha", "beta", "candidate", or "final". The version_info value corresponding to Python version 2.0 is (2,0,0,'final',0). Components are also accessible by name, so sys.version_info[0] is equivalent to sys.version_info.major, and so on.
Note: The 'sys' module provides access to some variables used or maintained by the interpreter, as well as functions that interact strongly with the interpreter.
Python code examples are as follows:
import sys print("Python version") print (sys.version) print("Version info.") print (sys.version_info)
Output:
Python version 3.5.2 (default, Sep 10 2016, 08:21:44) [GCC 5.4.0 20160609] Version info. sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)
Related recommendations: "Python Tutorial"
The above is the detailed content of How to get the currently used Python version information? (code example). For more information, please follow other related articles on the PHP Chinese website!