To get the number of CPUs on a system in Python, you can use the multiprocessing
or os
module. Below are two ways to achieve this:
Using the multiprocessing
module:
main.py95 chars5 lines
Using the os
module:
main.py69 chars5 lines
Both methods return the number of available CPUs on the system. This information can be useful in multiprocessing programs, or for hardware monitoring applications.
gistlibby LogSnag