Wednesday, September 24, 2025
HomeLanguagesPython | platform.uname() Method

Python | platform.uname() Method

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: 

 

RELATED ARTICLES

Most Popular

Dominic
32316 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6680 POSTS0 COMMENTS
Nicole Veronica
11852 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6794 POSTS0 COMMENTS
Ted Musemwa
7070 POSTS0 COMMENTS
Thapelo Manthata
6751 POSTS0 COMMENTS
Umr Jansen
6761 POSTS0 COMMENTS