python 判斷操作系統類型


 1 #!/bin/python
 2 #
 3 import platform
 4 
 5 def TestPlatform():
 6     print ("----------Operation System--------------------------")
 7     #Windows will be : (32bit, WindowsPE)
 8     #Linux will be : (32bit, ELF)
 9     print(platform.architecture())
10 
11     #Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600
12     #Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final
13     print(platform.platform())
14 
15     #Windows will be : Windows
16     #Linux will be : Linux
17     print(platform.system())
18 
19     print ("--------------Python Version-------------------------")
20     #Windows and Linux will be : 3.1.1 or 3.1.3
21     print(platform.python_version())
22 
23 def UsePlatform():
24   sysstr = platform.system()
25   if(sysstr =="Windows"):
26     print ("Call Windows tasks")
27   elif(sysstr == "Linux"):
28     print ("Call Linux tasks")
29   else:
30     print ("Other System tasks")
31 
32 UsePlatform()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM