Sometimes, we want to check what OS a script is running on with Python.
In this article, we’ll look at how to check what OS a script is running on with Python.
How to check what OS a script is running on with Python?
To check what OS a script is running on with Python, we can use the platform
module.
For instance, we write
import platform
s = platform.system()
r = platform.release()
to call platform.system
to get the OS name.
And we call platform.release
to get the kernel version.
Conclusion
To check what OS a script is running on with Python, we can use the platform
module.