
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Access Underlying Platform's Identifying Data in Python
Functions in the platform module help us probe the underlying platform’s hardware, operating system, and interpreter version information.
architecture()
This function queries the given executable (defaults to the Python interpreter executable) for various architecture information.
>>> import platform >>> platform.architecture() ('64bit', '')
machine()
This function returns the machine type, e.g. 'i386'. An empty string is returned if the value cannot be determined.
>>> platform.machine() 'x86_64'
node()
This function returns the computer’s network name.
>>> platform.node() 'malhar-ubuntu'
platform(aliased=0, terse=0)
This function returns a single string identifying the underlying platform.
>>> platform.platform() 'Linux-4.13.0-46-generic-x86_64-with-debian-stretch-sid'
processor()
This function returns the (real) processor name.
>>> platform.processor() 'x86_64'
python_build()
This function returns a tuple (buildno, builddate)
>>> platform.python_build() ('default', 'Oct 13 2017 12:02:49')
python_compiler()
This function returns a string identifying the compiler used for compiling Python.
>>> platform.python_compiler() 'GCC 7.2.0'
python_implementation()
This function returns a string identifying the Python implementation. Possible return values are: ‘CPython’, ‘IronPython’, ‘Jython’, ‘PyPy’.
>>> platform.python_implementation() 'CPython'
python_version()
This function returns a string containing the Python version in the form 'major.minor.patchlevel'.
>>> platform.python_version() '3.6.3'
System()
This function returns the system/OS name
>>> platform.system() 'Linux'
uname()
Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.
>>> platform.uname() uname_result(system='Linux', node='malhar-ubuntu', release='4.13.0-46-generic', version='#51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018', machine='x86_64', processor='x86_64')