判断操作系统的三种方法:
1. sys.platform
 Windows操作系统:
 >>> sys.platform
 'win32'
 
 Linux操作系统:
 >>> sys.platform
 'linux'
 
2. os.name
 它的返回值有两种: nt 和 posix 。
 其中, nt 表示Windwos系操作系统, posix 代表类Unix或OS X系统
 
 Windows操作系统:
 >>> os.name
 'nt'
 
 Linux操作系统:
 >>> os.name
 'posix'
 
 
3. platform模块:
 Windows操作系统:
 >>> platform.system()
 'Windows'
 >>> platform.release()
 '10'
 >>> platform.version()
 '10.0.17134'
 >>> platform.machine()
 'AMD64'
 >>> platform.uname()
 uname_result(system='Windows', node='DESKTOP-LBNGUN5', release='10', version='10.0.17134', machine='AMD64', processor='Intel64 Family 6 Model 142 Stepping 10, GenuineIntel')
 >>>
 
 Linux操作系统:
 >>> platform.system()
 'Linux'
 >>> platform.release()
 '3.10.0-693.21.1.el7.x86_64'
 >>> platform.version()
 '#1 SMP Wed Mar 7 19:03:37 UTC 2018'
 >>> platform.machine()
 'x86_64'
 >>> platform.uname()
 uname_result(system='Linux', node='localhost.localdomain', release='3.10.0-693.21.1.el7.x86_64', version='#1 SMP Wed Mar 7 19:03:37 UTC 2018', machine='x86_64', processor='x86_64')
 >>>
posted on 2018-07-10 21:38  仙寓游子  阅读(1307)  评论(0编辑  收藏  举报