日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

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

系統 1753 0

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

代碼如下:

復制代碼 代碼如下:

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


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 朝阳市| 佛学| 溆浦县| 康保县| 青阳县| 大埔县| 江西省| 宁都县| 迁安市| 泸州市| 长乐市| 筠连县| 建昌县| 裕民县| 大丰市| 嘉峪关市| 米易县| 洪洞县| 九江市| 城固县| 长白| 垣曲县| 土默特右旗| 永济市| 太康县| 嘉黎县| 屏东市| 长治县| 集安市| 和林格尔县| 岳阳市| 凤庆县| 日喀则市| 乐至县| 洪江市| 包头市| 昆明市| 临颍县| 玉龙| 新蔡县| 疏勒县|