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

首頁(yè) > 編程 > Python > 正文

Python判斷操作系統(tǒng)類型代碼分享

2020-02-23 06:12:09
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

經(jīng)常地我們需要編寫(xiě)跨平臺(tái)的腳本,但是由于不同的平臺(tái)的差異性,我們不得不獲得當(dāng)前所工作的平臺(tái)(操作系統(tǒng)類型)。

代碼如下:

代碼如下:
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()

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 开江县| 航空| 南澳县| 融水| 武穴市| 牡丹江市| 桃园市| 赣榆县| 尤溪县| 托里县| 堆龙德庆县| 大余县| 鹰潭市| 赣州市| 迁安市| 宝兴县| 逊克县| 保定市| 抚远县| 桃江县| 怀仁县| 汉源县| 镇安县| 阜新市| 枣阳市| 武定县| 顺平县| 建平县| 寻甸| 姚安县| 蒙山县| 西华县| 衢州市| 尖扎县| 巴东县| 松江区| 长海县| 三门峡市| 龙山县| 贵州省| 田东县|