简体   繁体   中英

Check python version build number

I need to check python version using a python script. I know that sys.version_info and platform.python_version() are used for the purpose but the problem is that the value they return are :

(2, 6, 6, 'final', 0) and 2.6.6

But I also need the the build number for my use-case which can be generated by rpm -qa | grep python* rpm -qa | grep python* , eg :

python-2.7.5-48.el7.x86_64

(build Number here being 48..) Is there any way to do it using a python script ?

You can use the architecture method in platform module

import platform
print platform.python_version()
print platform.architecture()
print "Version: {}, Architecture: {}".format(platform.python_version(), platform.architecture()[0])

Result:

2.7.13
('32bit', 'WindowsPE')
Version: 2.7.13, Architecture: 32bit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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