How to get the currently used Python version information? (code example)

藏色散人
Release: 2019-03-21 14:48:36
Original
4346 people have browsed it

This article mainly introduces how to obtain the current Python version. I hope it will be helpful to friends in need!

How to get the currently used Python version information? (code example)

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)
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template