日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

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

參考文獻:http://bbs.chinaunix.net/thread-1848086-1-1.html

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

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打開以后執行上述方法,其輸出結果如下圖所示。


本文轉自xwdreamer博客園博客,原文鏈接http://www.cnblogs.com/xwdreamer/p/3310134.html,如需轉載請自行聯系原作者

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。