Tuesday, July 7, 2026
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

4 COMMENTS

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12015 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7263 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6968 POSTS0 COMMENTS