Home » Python platform module

Python platform module

Oracle Java Certification
Java SE 11 Developer (Upgrade) [1Z0-817]
Java SE 11 Programmer I [1Z0-815] Practice Tests
1 Year Subscription
Java SE 11 Programmer II [1Z0-816] Practice Tests
Spring Framework Basics Video Course

The platform module in Python is used to access the underlying platform’s data,
this means information about the device, it’s operating system, Python version, etc

Usage

You start with importing the platform module in your program

import platform

Functions

platform.architecture()
returns information about the bit architecture

platform.machine()
returns the machine type

platform.node()
returns the computer’s network name

platform.platform()
returns a single string identifying the underlying platform with as much useful
information as possible.

platform.processor()
returns the (real) processor name

platform.python_build()
returns a tuple (buildno, builddate) stating the Python build number and
date as strings.

platform.python_compiler()
returns a string identifying the compiler used for compiling Python.

platform.python_version()
returns the Python version as string ‘major.minor.patchlevel’

platform.python_implementation()
returns a string identifying the Python implementation.

platform.release()
returns the system’s release

platform.system()
returns the system/OS name

platform.version()
returns the system’s release version

platform.uname()
returns a tuple of strings (system, node, release, version, machine, processor)
identifying the underlying platform.

 

Example

 

import platform

print ('uname:', platform.uname())
print ('system :', platform.system())
print ('node :', platform.node())
print ('release :', platform.release())
print ('version :', platform.version())
print ('machine :', platform.machine())
print ('processor:', platform.processor())

Video

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More