How to identify which OS Python is running on?
You can use the platform
module in Python to identify which operating system the code is running on. The platform.system()
function returns the name of the operating system. For example:
This will output the name of the operating system, such as 'Windows', 'Linux', or 'Darwin' for macOS.
Alternatively, you can use os.name
This will return 'nt' for Windows, 'posix' for Linux and MacOS.