首页 > 编程语言 > 详细

python 判断操作系统以及操作系统版本号

时间:2019-05-19 20:00:51      阅读:102      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/python3
# coding=gbk
import platform
if __name__ == ‘__main__‘:
plat_tuple=platform.architecture()
system=platform.system()
plat_version=platform.platform()
if system == ‘Windows‘:
log.info(‘this is windows system‘)
log.info(‘version is: ‘+plat_version)
elif system == ‘Linux‘:
log.info(‘this is linux system ‘)
log.info(‘version is: ‘+plat_version)
  

 for windows :

C:\Python37\python.exe C:/Users/Administrator/PycharmProjects/checkTest/src/subprocess_popen.py
[INFO]2019-05-19 19:34:28 Sun --app-- subprocess_popen.py>><module> function ::at line 42 :
this is windows system
[INFO]2019-05-19 19:34:28 Sun --app-- subprocess_popen.py>><module> function ::at line 43 :
version is: Windows-7-6.1.7601-SP1

 for linux 

[root@hostuser src]# python3 subprocess_popen.py
[INFO]2019-05-19 19:31:39 Sun --app-- subprocess_popen.py:
this is linux system
[INFO]2019-05-19 19:31:39 Sun --app-- subprocess_popen.py:
version is: Linux-3.10.0-957.10.1.el7.x86_64-x86_64-with-centos-7.6.1810-Core

 

python 判断操作系统以及操作系统版本号

原文:https://www.cnblogs.com/SunshineKimi/p/10890415.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!