欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python的platform模块的使用

程序员文章站 2022-06-15 11:40:32
platform是用来获取操作系统的信息的模块,具体见文档[root@VM_0_9_centos ~]# pythonPython 3.7.0 (default, Jun 28 2018, 13:15:42) [GCC 7.2.0] :: Anaconda, Inc. on linuxType "help", "copyright", "credits" or "license" for more information.>>> import platform>>...

platform是用来获取操作系统的信息的模块,具体见文档

文档可能需要外网,不一定加载的出来,这里有现成的(ltsd)

[root@VM_0_9_centos ~]# python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.uname()
uname_result(system='Linux', node='VM_0_9_centos', release='3.10.0-862.el7.x86_64', version='#1 SMP Fri Apr 20 16:44:24 UTC 2018', machine='x86_64', processor='x86_64')
>>> platform.uname()[1]
'VM_0_9_centos'
>>> platform.uname()[4]
'x86_64'
>>> platform.uname()[0]
'Linux'
>>> platform.machine()
'x86_64'
>>> platform.platform()
'Linux-3.10.0-862.el7.x86_64-x86_64-with-centos-7.5.1804-Core'
>>> platform.node()
'VM_0_9_centos'
>>> platform.python_compiler()
'GCC 7.2.0'
>>> platform.python_branch()
''
>>> platform.python_implementation()
'CPython'
>>> platform.python_revision()
''
>>> platform.python_version()
'3.7.0'
>>> platform.java_ver()
('', '', ('', '', ''), ('', '', ''))
>>> platform.win32_ver()
('', '', '', '')
>>> platform.dist()
__main__:1: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5
('centos', '7.5.1804', 'Core')
>>> platform.libc_ver()
('glibc', '2.9')

 

本文地址:https://blog.csdn.net/zhou_438/article/details/107658599

相关标签: Python