判断系统

判断系统

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# jihongrui@jsqix.com

import os
#winodws will be "nt" ,Linux will be "posix"
print os.name

import platform


def TestPlatform():
    print ("----------Operation System--------------------------")
    #Windows will be : (32bit, WindowsPE)
    #Linux will be : (32bit, ELF)
    print(platform.architecture())

    #Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600
    #Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final
    print(platform.platform())

    #Windows will be : Windows
    #Linux will be : Linux
    print(platform.system())

    print ("--------------Python Version-------------------------")
    #Windows and Linux will be : 3.1.1 or 3.1.3
    print(platform.python_version())

def UsePlatform():
  sysstr = platform.system()
  if(sysstr =="Windows"):
    print ("Call Windows tasks")
  elif(sysstr == "Linux"):
    print ("Call Linux tasks")
  else:
    print ("Other System tasks")

UsePlatform()
TestPlatform()
'''
winodws:
nt
Call Windows tasks
----------Operation System--------------------------
('64bit', 'WindowsPE')
Windows-7-6.1.7601-SP1
Windows
--------------Python Version-------------------------
2.7.11

Linux:
posix
Call Linux tasks
----------Operation System--------------------------
('64bit', 'ELF')
Linux-2.6.32-573.el6.x86_64-x86_64-with-centos-6.7-Final
Linux
--------------Python Version-------------------------
2.6.6

'''
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 在iOS开发过程中,如果要使用到一些跟特定系统版本特性有关的功能,或者要适配低版本系统的用户,还有一些方法是新版本...
    Cloudox_阅读 10,226评论 0 2
  • 判断系统版本的方法(用于方法的系统适配) 字数658阅读597评论1喜欢5 有一些方法在很久之前就有的,在高版本的...
    小枫123阅读 1,814评论 0 0
  • 有一些方法在很久之前就有的,在高版本的系统上使用可能会有问题,此时就需要判断用户的系统版本来选择执行哪一种方法了....
    Callmewenxi阅读 18,451评论 3 23
  • 很多系统方法都有版本支持的说明,所以对于支持多个系统版本,需要判断系统版本来执行方法。比如: 第一个方法只支持7-...
    罗淞阅读 5,457评论 0 0
  • 依然很累,边说话都很疲惫。想休息却有事情需要处理,唯有拖着疲惫的身体去上班。 打完卡就不想动了。韦仔却发信息来叫找...
    流浪痴人阅读 1,801评论 0 0

友情链接更多精彩内容