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