To get the system architecture in Python, you can use the platform
module. The platform
module provides a way to retrieve the system's hardware and OS details, including the architecture.
Here's an example code snippet to get the system architecture using platform
:
main.py120 chars7 lines
The platform.architecture()
function returns a tuple containing two elements: the first element is the system's architecture (such as "32bit" or "64bit"), and the second element is the Python interpreter's build information (such as "MSC v.1916 32 bit (Intel)"). In this case, we only need the first element, so we use the [0]
index to access it.
This code will output something like:
main.py27 chars2 lines
gistlibby LogSnag