Display the computer's OS and CPU core in Python
Last Updated on 2020-10-05 by Clay
Introduction
When we developing a Python project, sometimes we need to check which OS is user's current operating system, because of different operating systems we may have to use different methods to implement the same function.
In my recent project, I also need to know how many CPU cores the user has to implement a multi-threaded program, so, by the way, it is recorded here.
simply put, the platform module can be used to test the user operating system, and the cpu_count()
function in multiprocessing module can be used to calculate the number of CPU cores.