Menu Close

Python Platform Module

Python Platform Module

In this guide, we are going to learn about the Python Platform module. Platform module is a built-in module in Python programming which is used to retrieve the system information.

In the previous tutorial, we have seen all about the Python base64 module. If you get the information about the system or machine, Then the Python platform is the best module.

What is Python Platform Module?

In Python, Platform is a built-in Python module that means you don’t need to install this module using the pip command.
Python platform module is used to access underlying’s data of the machine or system such as hardware, interpreter version, and operating system, etc.

How to Use Python Platform Module?

As you know, the platform is a built-in Python module, That means the Platform comes pre-installed with Python.
To use the Platform module, you have to import it using the import keyword.

import platform

Python Platform Module Function:

In Python programming, the Platform module provides various useful functions that are used to get information about your system.

platform.architecture():

The platform.architecture() function return the information about system architecture.

import platform
x = platform.architecture()
print(x)

Output will be:- (’32bit’, ‘WindowsPE’)

platform.machine()

The platform.machine() function return the information about machine type.

import platform
x = platform.machine()
print(x)

Output will be:- x86

platform.node()

The platform.node() function returns the computer network name.

import platform
x = platform.node()
print(x)

Output will be:- DESKTOP-00V9AQU

platform.platform()

The platform.platform() function returns a single string that identifies the underlying platform.

import platform
x = platform.platform()
print(x)

Output will be:- Windows-10-10.0.18362-SP0

platform.processor()

The platform.processor() function returns the processor.

import platform
x = platform.processor()
print(x)

Output will be:- x86 Family 6 Model 37 Stepping 2, GenuineIntel

platform.python_build()

The platform.python_build() function return the python build number and date as string.

import platform
x = platform.python_build()
print(x)

Output will be:- (‘v3.7.1:260ec2c36a’, ‘Oct 20 2018 14:57:15’)

platform.python_compiler()

The platform.python_compiler() function returns the compiler used for compiling Python.

import platform
x = platform.python_compiler()
print(x)

Output will be:- MSC v.1926 32 bit (Intel)

platform.implementation()

The platform.python_implementation() function return the string identify the python implementation.

import platform
x = platform.python_implementation()
print(x)

Output will be:- CPython

platform.python_version()

The platform.python_version() function return the python version.

import platform
x = platform.python_version()
print(x)

Output will be:- 3.8.5

The platform.release()

The platform.release() function return the system release.

import platform
x = platform.release()
print(x)

Output will be:- 10

platform.system()

The platform.system() function return the system name.

import platform
x = platform.system()
print(x)

Output will be:- Windows

platform.version()

The platform.version() function return the system version.

import platform
x = platform.version()
print(x)

Output will be:- 10.0.18362

platform.uname()

The platform.uname() function returns the combination of system, node, release, processor, version, and machine.

import platform
x = platform.uname()
print(x)

Output will be:- uname_result(system=’Windows’, node=’DESKTOP 00V9AQU’, release=’10’, version=’10.0.18362′, machine=’x86′, processor=’x86 Family 6 Model 37 Stepping 2, GenuineIntel’)

platform.win32_ver()

The platform.win32_ver() function return the tuple that contains additional information such as OS release, OS version, service pack, and OS Type.

import platform
x = platform.win32_ver()
print(x)

Output will be:- (’10’, ‘10.0.18362’, ‘SP0’, ‘Multiprocessor Free’)

platform.libc_ver()

The platform.libc_ver() function return the tuple additional information such as library and version.

platform.mac_ver()

The platform.mac_ver() function return the tuple additional information such as release, version and machine of Mac OS.

Note:- All the output coming according to our operating system. It might be different in your case.

Conclusion

In this article, you have learned the Python Platform module. The platform module is the best Python built-in module to get information about the system.
if you want to work with the system, Then you can go with the Python platform module.

I hope this tutorial will help you. If you like this article, please share with your friends who want to learn Python programming from scratch to advanced.

For More Information: Click Here

Previous Article
Next Article

Related Posts

Leave a Reply