| 
 Python 如何快速获取电脑 CPU 核心 线程数的几种办法  
CPU 拥有多少核心多少线程,通过 Python 可快速找出,特别是当前流行的多核 CPU。 
 
多核多线程 CPU 是很多应用程序高效运行的前提,虽然编写能充分调用所有 CPU 线程的应用程序有一定难度。 
 
快速编辑重构 批处理式 数字 Python IDE 集成开发环境 (自带 Cython PyInstaller 批处理工具) 
http://dt.digitser.cn/zh-CN/ide/idepy/index.html 
 
基于纯 Python 
- >>> from os import cpu_count
 
  
- >>> cpu_count()
 
  
- 4
 
  
- >>>
 
  复制代码 
- >>> from multiprocessing import cpu_count
 
  
- >>> cpu_count()
 
  
- 4
 
  
- >>>
 
  复制代码 
基于 PyQt5 
- >>> from PyQt5.QtCore import QThread
 
  
- >>> QThread.idealThreadCount()
 
  
- 4
 
  
- >>>
 
  复制代码 
 
基于 PySide2 
- >>> from PySide2.QtCore import QThread
 
  
- >>> QThread.idealThreadCount()
 
  
- 4
 
  
- >>>
 
  复制代码 
扫一扫关注 德云社区 微信公众号  
版权声明: 
本文为独家原创稿件,版权归 德云社区,未经许可不得转载。 
 |