platform模块
import platform '''
python中,platform模块给我们提供了很多方法去获取操作系统的信息
如:
import platform
platform.platform() #获取操作系统名称及版本号,'Windows-7-6.1.7601-SP1'
platform.version() #获取操作系统版本号,'6.1.7601'
platform.architecture() #获取操作系统的位数,('32bit', 'WindowsPE')
platform.machine() #计算机类型,'x86'
platform.node() #计算机的网络名称,'hongjie-PC'
platform.processor() #计算机处理器信息,'x86 Family 16 Model 6 Stepping 3, AuthenticAMD'
platform.uname() #包含上面所有的信息汇总,uname_result(system='Windows', node='hongjie-PC',
release='7', version='6.1.7601', machine='x86', processor='x86 Family
Model 6 Stepping 3, AuthenticAMD') 还可以获得计算机中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()
''' #global var
#是否显示日志信息
SHOW_LOG = True def get_platform():
'''获取操作系统名称及版本号'''
return platform.platform() def get_version():
'''获取操作系统版本号'''
return platform.version() def get_architecture():
'''获取操作系统的位数'''
return platform.architecture() def get_machine():
'''计算机类型'''
return platform.machine() def get_node():
'''计算机的网络名称'''
return platform.node() def get_processor():
'''计算机处理器信息'''
return platform.processor() def get_system():
'''获取操作系统类型'''
return platform.system() def get_uname():
'''汇总信息'''
return platform.uname() def get_python_build():
''' 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() def get_python_branch():
'''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() def show_python_all_info():
'''打印python的全部信息'''
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())) def show_python_info():
'''只打印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()) def show_os_all_info():
'''打印os的全部信息'''
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())) def show_os_info():
'''只打印os的信息,没有解释部分'''
print(get_platform())
print(get_version())
print(get_architecture())
print(get_machine())
print(get_node())
print(get_processor())
print(get_system())
print(get_uname()) def test():
print('操作系统信息:')
if SHOW_LOG:
show_os_all_info()
else:
show_os_info()
print('#' * 50)
print('计算机中的python信息:')
if SHOW_LOG:
show_python_all_info()
else:
show_python_info() def init():
global SHOW_LOG
SHOW_LOG = True def main():
init()
test() if __name__ == '__main__':
main()
platform模块的更多相关文章
- python之platform模块
python之platform模块 ^_^第三个模块从天而降喽!! 函数列表 platform.system() 获取操作系统类型,windows.linux等 platform.platform() ...
- Python第十一天 异常处理 glob模块和shlex模块 打开外部程序和subprocess模块 subprocess类 Pipe管道 operator模块 sorted函数 os模块 hashlib模块 platform模块 csv模块
Python第十一天 异常处理 glob模块和shlex模块 打开外部程序和subprocess模块 subprocess类 Pipe管道 operator模块 sorted函 ...
- python3之platform模块
platform模块可以获取操作系统的相关信息. >>> platform.system() #获取系统名称 'Linux' >>> platform.archit ...
- python 模块之platform模块(基本了解)
# -*- coding: cp936 -*-#python 27#xiaodeng#python 模块之platform模块(基本了解)#获取底层平台的识别数据 #知道该模块用途即可,需要使用时直接 ...
- platform 模块
python中,platform 模块给我们提供了很多方法去获取操作系统的信息,如: import platform platform.platform() #获取操作系统名称及版本号 'Window ...
- Python platform 模块
Python platform 模块 platform 模块用于查看当前操作系统的信息,来采集系统版本位数计算机类型名称内核等一系列信息. 使用方法: import platform # 获取操作系统 ...
- platform模块和ctypes模块
一.ctypes模块 Python 的 ctypes 要使用 C 函数,需要先将 C 编译成动态链接库的形式,即 Windows 下的 .dll 文件,或者 Linux 下的 .so 文件.先来看一下 ...
- python platform模块
该模块用来访问平台相关属性. 常见属性和方法 系统名称 platform.system() 返回系统/操作系统名称,例如“Linux”,“Windows” >>> platform. ...
- python学习之platform模块
该模块用来访问平台相关属性. 常见属性和方法 平台架构 platform.machine() 返回平台架构.若无法确定,则返回空字符串. >>> platform.machine() ...
随机推荐
- 【简单易用的傻瓜式图标设计工具】Logoist 3.1 for Mac
[简介] Logoist 是一款Mac上强大易用的傻瓜式图标设计制作工具,通过使用内置模板和预设效果,您可以立即创建高质量的图形内容和艺术作品.通过使用该应用程序,可用于制作图标LOGO. 一款用于创 ...
- OS + Linux RedHat 6.3 QA
s 问题1:could not open session 解决办法 https://blog.csdn.net/qq_40809549/article/details/82658720 解决1: 配置 ...
- JAVA-序列化深拷贝对象
序列化拷贝方法 @SuppressWarnings("unchecked") public static <T extends Serializable> T clon ...
- springBootJpa的复杂查询
分页 /** * 条件查询+分页 * @param whereMap * @param page * @param size * @return */ public Page<CaseManag ...
- 13个.Net开源的网络爬虫
请点击此处输入图片描述 1:.Net开源的跨平台爬虫框架 DotnetSpider Star:430 DotnetSpider这是国人开源的一个跨平台.高性能.轻量级的爬虫软件,采用 C# 开发.目前 ...
- jQuery使用(六):DOM操作之元素包裹、克隆DOM与data的综合应用
包裹 wrap() wrapInner() wrapAll() unwrap() clone() 数据缓存机制 data 文档处理(包裹) 1.1.wrap()--将所匹配的元素用其他元素结构化标签包 ...
- 算法实践——舞蹈链(Dancing Links)算法求解数独
在“跳跃的舞者,舞蹈链(Dancing Links)算法——求解精确覆盖问题”一文中介绍了舞蹈链(Dancing Links)算法求解精确覆盖问题. 本文介绍该算法的实际运用,利用舞蹈链(Dancin ...
- PHP7 学习笔记(十四)Reids 键空间通知配合TP5 实现分布式延时任务
测试环境:windows 10 + phpStudy 配置redis配置文件 redis.windows.conf notify-keyspace-events "Ex" 重启re ...
- python里的input
python2和python3的input是不同的 python3的input 对于python3,只有input,官方文档里是这样描述的 def input(*args, **kwargs): # ...
- 三.HashMap原理及实现学习总结
HashMap是Java中最常用的集合类框架之一,是Java语言中非常典型的数据结构.本篇主要是从HashMap的工作原理,数据结构分析,HashMap存储和读取几个方面对其进行学习总结.关于Hash ...