您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Python判断操作系统类型代码分享

2024/2/18 5:40:08发布14次查看
经常地我们需要编写跨平台的脚本,但是由于不同的平台的差异性,我们不得不获得当前所工作的平台(操作系统类型)。
代码如下:
复制代码 代码如下:
import platformdef 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()
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product