python中,platform模块给我们提供了很多方法去获取操作系统的信息
如:
import platform
platform.platform() # 获取操作系统名称及版本号,'Linux-3.13.0-46-generic-i686-with-Deepin-2014.2-trusty'
platform.version() # 获取操作系统版本号,'#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015'
platform.architecture() # 获取操作系统的位数,('32bit', 'ELF')
platform.machine() # 计算机类型,'i686'
platform.node() # 计算机的网络名称,'XF654'
platform.processor() # 计算机处理器信息,''i686'
platform.uname() # 包含上面所有的信息汇总,('Linux', 'XF654', '3.13.0-46-generic', '#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015', 'i686', 'i686')
还可以获得计算机中python的一些信息:
import platform
platform.python_build()
platform.python_compiler()
platform.python_branch()
platform.python_implementation()
platform.python_revision()
platform.python_version()
platform.python_version_tuple()
-
-
-
-
-
-
-
-
-
python中,platform模块给我们提供了很多方法去获取操作系统的信息
-
-
-
platform.platform() #获取操作系统名称及版本号,'Linux-3.13.0-46-generic-i686-with-Deepin-2014.2-trusty'
-
platform.version() #获取操作系统版本号,'#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015'
-
platform.architecture() #获取操作系统的位数,('32bit', 'ELF')
-
platform.machine() #计算机类型,'i686'
-
platform.node() #计算机的网络名称,'XF654'
-
platform.processor() #计算机处理器信息,''i686'
-
platform.uname() #包含上面所有的信息汇总,('Linux', 'XF654', '3.13.0-46-generic', '#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015', 'i686', 'i686')
-
-
-
-
-
platform.python_compiler()
-
-
platform.python_implementation()
-
platform.python_revision()
-
platform.python_version()
-
platform.python_version_tuple()
-
-
-
-
-
-
-
-
-
return platform.platform()
-
-
-
-
return platform.version()
-
-
-
-
return platform.architecture()
-
-
-
-
return platform.machine()
-
-
-
-
-
-
-
-
return platform.processor()
-
-
-
-
-
-
-
-
-
-
-
''' the Python build number and date as strings'''
-
return platform.python_build()
-
-
def get_python_compiler():
-
'''Returns a string identifying the compiler used for compiling Python'''
-
return platform.python_compiler()
-
-
-
'''Returns a string identifying the Python implementation SCM branch'''
-
return platform.python_branch()
-
-
def get_python_implementation():
-
'''Returns a string identifying the Python implementation. Possible return values are: ‘CPython’, ‘IronPython’, ‘Jython’, ‘PyPy’.'''
-
return platform.python_implementation()
-
-
def get_python_version():
-
'''Returns the Python version as string 'major.minor.patchlevel'
-
-
return platform.python_version()
-
-
def get_python_revision():
-
'''Returns a string identifying the Python implementation SCM revision.'''
-
return platform.python_revision()
-
-
def get_python_version_tuple():
-
'''Returns the Python version as tuple (major, minor, patchlevel) of strings'''
-
return platform.python_version_tuple()
-
-
-
-
print('获取操作系统名称及版本号 : [{}]'.format(get_platform()))
-
print('获取操作系统版本号 : [{}]'.format(get_version()))
-
print('获取操作系统的位数 : [{}]'.format(get_architecture()))
-
print('计算机类型 : [{}]'.format(get_machine()))
-
print('计算机的网络名称 : [{}]'.format(get_node()))
-
print('计算机处理器信息 : [{}]'.format(get_processor()))
-
print('获取操作系统类型 : [{}]'.format(get_system()))
-
print('汇总信息 : [{}]'.format(get_uname()))
-
-
-
-
-
-
print(get_architecture())
-
-
-
-
-
-
-
def show_python_all_info():
-
-
print('The Python build number and date as strings : [{}]'.format(get_python_build()))
-
print('Returns a string identifying the compiler used for compiling Python : [{}]'.format(get_python_compiler()))
-
print('Returns a string identifying the Python implementation SCM branch : [{}]'.format(get_python_branch()))
-
print('Returns a string identifying the Python implementation : [{}]'.format(get_python_implementation()))
-
print('The version of Python : [{}]'.format(get_python_version()))
-
print('Python implementation SCM revision : [{}]'.format(get_python_revision()))
-
print('Python version as tuple : [{}]'.format(get_python_version_tuple()))
-
-
-
'''只打印python的信息,没有解释部分'''
-
print(get_python_build())
-
print(get_python_compiler())
-
print(get_python_branch())
-
print(get_python_implementation())
-
print(get_python_version())
-
print(get_python_revision())
-
print(get_python_version_tuple())
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
if __name__ == '__main__':
-