- The platform module in Python is used to access the underlying platform’s data, such as hardware, operating system, and interpreter version information.
- This module tries to retrieve as much platform-identifying data as possible.
- platform module comes with python basic library so we don't need to install it Externally.
You can start with importing the platform module in your program
Syntax:
#without alias
import platform
#With Alias
import platform as <AnyShortName>
Example:
#without alias
import platform
#With Alias
import platform as pl
#to Get the help of platform module use
print(help(platform))
#To get the list of functions and Variables
print(dir(platform))
- System() returns the Operating system Name e.g. 'Linux','windows','Java'
Example
import platform
#Get operating system name
name=platform.system()
print(name)
Output:
Windows
- Returns a tuple (bits, linkage) which contain information about the bit architecture and the linkage format used for the executable.
- Both values are returned as strings. Example:
import platform
#Get operating architecture
name=platform.architecture()
print(name)
Output:
('64bit', 'WindowsPE')
- node() returns an Computer network name.
- An empty string is returned if value can not be determined.
Example:
import platform
#Get computer name in network
name=platform.node()
print(name)
Output:
'EKPubgikar'
- Returns The Actual processor name of machine. Example:
import platform
#Get processor name
name=platform.processor()
print(name)
Output:
'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
- Retruns the machine type e.g.'AMD64' Example:
import platform
#Get the machine type
name=platform.machine()
print(name)
Output:
'AMD64'
- Return the Operating system release version Example:
import platform
#Get the Release Version
name=platform.version()
print(name)
Output:
'10.0.17763'
- Returns the python version Example:
import platform
#Get the pthon version
name=platform.python_version()
print(name)
Output:
'3.7.3'
- Returns a tuple of strings (system, node, release, version, machine, processor) Example:
import platform
#Get the Uname Details
details=platform.uname()
print(details)
Output:
uname_result(system='Windows',
node='EKPubgikar',
release='10',
version='10.0.17763',
machine='AMD64',
processor='Intel64 Family 6 Model 58 Stepping 9, GenuineIntel')
- Returns a tuple (buildno, builddate) stating the Python build number and date as strings.
- Returns a string identifying the compiler used for compiling Python.
platform module official documentation Here