python program to fin os info

In this example, you will learn find operated system information using python.

In order to make an application cross-platform, there may be times when you want to inspect the operating system and take a different action depending on whether it is Linux, Mac, Windows, or other.

These examples will show you how to find relevant information about operating system using python platform modules.

Example :

#python program to find operating system information
import platform

print(platform.system())  # e.g. Windows, Linux, Darwin
print(platform.architecture())  # e.g. 64-bit
print(platform.machine())  # e.g. x86_64
print(platform.node())  # hostname
print(platform.processor())  # processor information
print(platform.release())  # version of os 

Output :

('64bit', 'WindowsPE')
Intel64 Family 6 Model 165 Stepping 2, GenuineIntel

Explanation :

Those are common function of platform module in python which are used our program. The platform.system() function returns os name. In this case it's windows.

Share your thoughts

Ask anything about this examples