Saturday, May 9, 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

2 COMMENTS

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS