利用该模块可以获取系统平台与python平台的信息。


import platform'''python中,platform模块给我们提供了很多方法去获取操作系统的信息如:import platformplatform.platform()   #获取操作系统名称及版本号,'Windows-7-6.1.7601-SP1'platform.version()    #获取操作系统版本号,'6.1.7601'platform.architecture()   #获取操作系统的位数,('32bit', 'WindowsPE')platform.machine()    #计算机类型,'x86'platform.node()       #计算机的网络名称,'Natural-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 Family16 Model 6 Stepping 3, AuthenticAMD')还可以获得计算机中python的一些信息:import platformplatform.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 = Truedef 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_LOGSHOW_LOG = Truedef main():init()test()if __name__ == '__main__':main()

python中的platform模块获取平台信息相关推荐

  1. python中的系统模块_python中一些获取系统信息的模块

    1.platform模块 python中,platform模块给我们提供了很多方法去获取操作系统的信息 如: import platform platform.platform() #获取操作系统名称 ...

  2. Python中的常用模块

    1.sys模块(内置模块) 在sys模块中定义了一些函数和变量,用来设置和获取系统的信息. # Python中的常用模块:sys模块 import sys sys.path.append('./tes ...

  3. python中的log模块笔记

    日志相关概念 logging模块简介 使用logging提供的模块级别的函数记录日志 logging模块日志流处理流程 使用logging四大组件记录日志 配置logging的几种方式 向日志输出中添 ...

  4. python中产生随机数模块_Python中random模块生成随机数详解

    Python中的random模块用于生成随机数.下面介绍一下random模块中最常用的几个函数. random.random random.random()用于生成一个0到1的随机符点数: 0 < ...

  5. Python中的logging模块

    http://python.jobbole.com/86887/ 最近修改了项目里的logging相关功能,用到了python标准库里的logging模块,在此做一些记录.主要是从官方文档和stack ...

  6. python中tkinter模块_使用Python中的tkinter模块作图的方法

    python简述: Python是一种解释型.面向对象.动态数据类型的高级程序设计语言.自从20世纪90年代初Python语言诞生至今,它逐渐被广泛应用于处理系统管理任务和Web编程.Python[1 ...

  7. python中的numpy模块

    参考  python中的numpy模块 - 云+社区 - 腾讯云 目录 NumPy 教程 学习本教程前你需要了解 NumPy 应用 相关链接 NumPy 安装 1.使用已有的发行版本 2.使用 pip ...

  8. 使用Python中的tabula模块进行pdf2excel转化时出现JAVA_NOT_FOUND_ERROR问题

    使用Python中的tabula模块进行pdf2excel转化时出现JAVA_NOT_FOUND_ERROR问题 1.python中pdf2excel转化模块的选用 1.1 pdfminer 1.2 ...

  9. python模拟浏览器模块_在Python中使用mechanize模块模拟浏览器功能

    知道如何快速在命令行或者python脚本中实例化一个浏览器通常是非常有用的. 每次我需要做任何关于web的自动任务时,我都使用这段python代码去模拟一个浏览器. import mechanize ...

最新文章

  1. adobe怎么统计字数_本科毕业论文怎么写(正文写作要点精华)
  2. Delphi笔记整理(二)
  3. 微信小程序的一些数据调用方式
  4. 【华为云技术分享】云图说|全新华为云云备份服务:为您的数据提供三合一的保障
  5. UGUI——基本组件
  6. 美食海报设计技巧?有机轻食饮食新趋势!
  7. android 模块混淆配置,使用android studio混淆多个模块
  8. 不懂算法的程序员不是好工程师!
  9. Base64转BufferedImage
  10. 基础知识复习(一)——C语言位运算符详解
  11. 印象笔记 离线版_印象笔记如何离线
  12. python爬虫-国家企业_国家企业信用公示系统的爬取
  13. mysql人物画像_用户画像智能匹配,用户画像的算法有哪些?
  14. 高等代数---欧几里得空间
  15. (华为社招岗位,部门---上海海思,GTS,海思,2012,华为云):北京北京北京!
  16. c语言总分和平均分,用C语言编程平均分数
  17. mysql同步数据_实现MySQL数据库数据的同步方法介绍
  18. 19 分布式缓存集群的伸缩性设计
  19. 计算机无法识别苹果手机,如何解决电脑无法识别iphone的问题?
  20. 30分钟java桌球小游戏_30分钟完成桌球小游戏项目

热门文章

  1. 单位冲激信号和数字信号处理
  2. idea中vue文件 游览器图标_vue项目中icon图标的完美引入
  3. python学习——yield和yield from
  4. XML 中的 ﹤![CDATA[ ]]
  5. 100个python算法超详细讲解:百钱百鸡
  6. GraphQL的认识与使用
  7. java ora-12505_Java Oracle本地主机连接错误(ORA-12505)
  8. 非递归实现二叉树的遍历
  9. 将uchar转换为Mat并显示出来
  10. 涵林同学21浙工大计算机考研心路历程(非正经、无干货)