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.
Headings of Contents
- 1 What is Python Platform Module?
- 2 How to Use Python Platform Module?
- 3 Python Platform Module Function:
- 3.1 platform.architecture():
- 3.2 platform.machine()
- 3.3 platform.node()
- 3.4 platform.platform()
- 3.5 platform.processor()
- 3.6 platform.python_build()
- 3.7 platform.python_compiler()
- 3.8 platform.implementation()
- 3.9 platform.python_version()
- 3.10 The platform.release()
- 3.11 platform.system()
- 3.12 platform.version()
- 3.13 platform.uname()
- 3.14 platform.win32_ver()
- 3.15 platform.libc_ver()
- 3.16 platform.mac_ver()
- 4 Conclusion
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, Which 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)
The output will be:- x86
platform.node()
The platform.node() function returns the computer network name.
import platform
x = platform.node()
print(x)
The 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)
The 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)
The output will be:- x86 Family 6 Model 37 Stepping 2, GenuineIntel
platform.python_build()
The platform.python_build() function returns the python build number and date as a 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)
The 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)
The 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 returns 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 returns the tuple additional information such as release, version, and machine of Mac OS.
Note:- All the output comes 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 it with your friends who want to learn Python programming from scratch to advanced.
For More Information: Click Here