The functionality is implemented in the sys module.
import sys
#Comfortable for people to see
print "--sys.version--"
print sys.version
print "\n--sys.version_info--"
print sys.version_info
print "\n--sys.hexversion--"
print sys.hexversion
If you want to make a script work only on certain versions or higher, write as follows.
assert sys.version_info >= (2, 5) #2.5 and later only
ASSERT sys.version_info >= (3, 5, 0) #3.5.0 and later only
AssertionError
occurs if it is below a certain version.
© 2024 OneMinuteCode. All rights reserved.