如何在python 2.4中获得cpuinfo。我想确定一台机器中的处理器数量。 (代码应该与操作系统无关)。我已经编写了Linux代码,但不知道如何使它适用于Windows。在python 2.4 for windows中的cpuinfo
import subprocess, re
cmd = 'cat /proc/cpuinfo |grep processor |wc'
d = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
lines = d.stdout.readlines()
lines = re.split('\s+', lines[0])
number_of_procs = int(lines[1])
假设我没有安装在Windows机器上的cygwin,我只是有python2.4。 请让我知道,如果有一些模块可以为此目的调用,或任何帮助编写此功能的代码。
感谢, 桑德亚
可能重复的[如何找出python中的CPU数量](http://stackoverflow.com/questions/1006289/how-to-find-out-the-number-of-cpus-in-python ) – sdolan 2011-02-08 07:01:14