python获取当前计算机的cpu数量的代码(Python code to get the number of CPUs of the current computer)

把代码过程比较重要的一些代码段做个记录,如下的代码是关于python获取当前计算机的cpu数量的代码,应该对码农们有一些用途。

from multiprocessing import cpu_countprint(cpu_count())

本机是四核电脑,返回结果:4

————————

Make a record of some important code segments in the code process. The following code is about Python obtaining the number of CPUs of the current computer. It should be used by coders.

from multiprocessing import cpu_countprint(cpu_count())

This machine is a quad core computer. The return result is: 4