Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check operating system

from sys import platform
if platform == "linux" or platform == "linux2":
    # linux
elif platform == "darwin":
    # OS X
elif platform == "win32":
    # Windows...
Comment

check os python

>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>> platform.version()
'5.1.2600'
Comment

detect operating system using python

import platform
my_os = platform.system()
print("OS in my system : ",my_os)

# Output - 
# OS in my system :  Linux
Comment

Python How To Check Operating System

import platform
my_os = platform.system()
print("OS in my system : ",my_os)
Comment

Python - How To Check Operating System

import platform 
my_os = platform.system() 
print("OS in my system : ",my_os)
Comment

Detect the Operating System Using the sys Module in Python

# 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
Comment

PREVIOUS NEXT
Code Example
Python :: python first day of last month 
Python :: logging python utf-8 
Python :: how to remove all spaces from a string in python 
Python :: random color python matplotlib 
Python :: tqdm in for loop 
Python :: remove None pandas 
Python :: runserver manage.py 
Python :: split string in the middle python 
Python :: 2 - 20 python 
Python :: superscript print python 
Python :: django integer field example 
Python :: remove multiple space python 
Python :: python url encoding 
Python :: python json dump utf8 
Python :: python dockerfile 
Python :: upgrade package python 
Python :: how to pass header in requests 
Python :: datetime one week ago python 
Python :: how to count stopwords in df 
Python :: create text in python if not exists 
Python :: python f string thousand separator 
Python :: python check if list contains elements of another list 
Python :: add favicon fastapi 
Python :: django queryset average of unique values 
Python :: zipfile python 
Python :: python roll dice 100 times 
Python :: normalize data python pandas 
Python :: python image read 
Python :: convert int to byte python 
Python :: django jinja subset string 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =