我想知道使用Python的本地机器上的CPU数量.当使用最佳扩展用户空间程序调用时,结果应该是user/real输出time(1).
Using the platform module in Python on my Windows laptop, I get the following output
import platform
platform.processor()
Run Code Online (Sandbox Code Playgroud)
'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
If I look at the Windows System Information, however, I am told that my processor is an Intel Core i5-3317U CPU at 1.70Ghz. How can I get Python to return processor information in this format?
我试图找出这个值存储在windows和osx中的位置,以便进行一些计算以更好地分配任务.
核心速度,单位为Hz
提前致谢.
使用platform.process()命令只返回名称而不是速度
我只是设法通过这个:
import subprocess
info=subprocess.check_output(["wmic","cpu","get", "name"])
print info.split('@')[1].split(' ')[1]
Run Code Online (Sandbox Code Playgroud)
但目前我无法判断它是否总能在每台机器上返回相同的结果(现在无法访问其他计算机)
我想要的东西会收到我的流程细节,就像我在linux中使用'ps'命令收到的那样,
获得2个基本类型 - CPU使用率和使用的内存.
今天为了得到这个我使用不舒服的方式:
subprocess.check_output(["ps", "aux"])
Run Code Online (Sandbox Code Playgroud)
........
并解析此输出..
任何想法或解决方案都可以接受!
谢谢!