from sys import platform
if platform == "linux" or platform == "linux2":
# linux
elif platform == "darwin":
# OS X
elif platform == "win32":
# Windows...
import platform
my_os = platform.system()
print("OS in my system : ",my_os)
# Output -
# OS in my system : Linux
import platform
my_os = platform.system()
print("OS in my system : ",my_os)
import platform
my_os = platform.system()
print("OS in my system : ",my_os)
# The sys module can also be used to find the operating system of the device.
# We use the platform attribute of the sys module to get the operating system’s name
# on our device.
import sys
my_os=sys.platform
print("OS in my system : ",my_os)
# Output:
# OS in my system : linux
# Whenever you want to specifically distinguish your system in between win32 and
# cygwin, this method can be very useful.
# This approach can also be helpful when we want to specifically distinguish your
# system in between win32 and cygwin.
# For other operating system sys.platform outputs as:
# `win32` for Windows(Win32)
# 'cygwin' for Windows(cygwin)
# 'darwin' for macOS
# 'aix' for AIX