Categories
Python Answers

How to determine if a Python shell is executing in 32bit or 64bit?

Spread the love

Sometimes, we want to determine if a Python shell is executing in 32bit or 64bit.

In this article, we’ll look at how to determine if a Python shell is executing in 32bit or 64bit.

How to determine if a Python shell is executing in 32bit or 64bit?

To determine if a Python shell is executing in 32bit or 64bit, we can use the platform module.

For instance, we write

import platform

print(platform.architecture()[0])

to call platform.architecture and get the first part from the list to either display '32bit' if it’s running on a 32 bit shell or '64bit' if it’s running on a 64 bit shell.

Conclusion

To determine if a Python shell is executing in 32bit or 64bit, we can use the platform module.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *