国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python判斷操作系統類型代碼分享

2019-11-25 18:04:33
字體:
來源:轉載
供稿:網友

經常地我們需要編寫跨平臺的腳本,但是由于不同的平臺的差異性,我們不得不獲得當前所工作的平臺(操作系統類型)。

代碼如下:

復制代碼 代碼如下:

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()

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 修文县| 台东县| 曲阜市| 德庆县| 泸州市| 太康县| 湖口县| 乐清市| 镶黄旗| 桑日县| 怀来县| 衡阳市| 三原县| 阿坝| 富源县| 个旧市| 白玉县| 洪江市| 穆棱市| 马龙县| 诸暨市| 特克斯县| 宜兰市| 南昌县| 兴宁市| 普宁市| 庆城县| 清水河县| 满洲里市| 淄博市| 高唐县| 龙海市| 上饶市| 绥化市| 鸡西市| 衡东县| 田林县| 达拉特旗| 克东县| 武胜县| 浪卡子县|