日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

python实例[判断操作系统类型]

發(fā)布時(shí)間:2023/12/15 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python实例[判断操作系统类型] 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參考文獻(xiàn):http://bbs.chinaunix.net/thread-1848086-1-1.html

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

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-Finalprint(platform.platform())#Windows will be : Windows#Linux will be : Linuxprint(platform.system())print ("--------------Python Version-------------------------")#Windows and Linux will be : 3.1.1 or 3.1.3print(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()//方法1
TestPlatform()//方法2

我安裝了python以后,使用python GUI打開以后執(zhí)行上述方法,其輸出結(jié)果如下圖所示。


本文轉(zhuǎn)自xwdreamer博客園博客,原文鏈接http://www.cnblogs.com/xwdreamer/p/3310134.html,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者

總結(jié)

以上是生活随笔為你收集整理的python实例[判断操作系统类型]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。