What is the platform.machine() in Python?

Overview

The platform module in Python provides functions that access information of the underlying platform (the operating system).

The platform.machine() method is used to return the machine type of the underlying platform. For example, i386, i686, x86_64.

Method signature

machine()

Parameters

This method has no parameters.

Return value

The return type will be a machine type or an empty string.

Code

import platform
print("platform.machine() = %s" % (platform.machine()))

Code explanation

  • Line 1: We import the platform module.
  • Line 3: We retrieve the machine type using the machine() method.