Open In App

Python | platform.uname() Method

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will learn how to detect the operating system that is currently being used in your system using Python.

Detect OS Using the platform Module in Python

The platform.uname() method in python is used to get information about the current operating system. This method returns information like name, release, and version of the current operating system, name of the machine on the network, and hardware identifier in the form of attributes of a tuple-like object.

Syntax of platform.uname()

Syntax: platform.uname() 

Return Type: This method returns a tuple-like object which has five attributes:

  • sysname: operating system name
  • nodename: name of the machine on the network (implementation-defined)
  • release: operating system release
  • version: operating system version
  • machine: hardware identifier

Check Operating System using platform.uname() method 

In this method, we are using the uname() method to get OS Python information.

Python3




import platform
 
print(platform.uname())


Output: 

 


Last Updated : 23 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads