Open In App

Check whether Python shell is executing in 32bit or 64bit mode on OS

In this article, we are going to see how to check if the Python shell is executing in 32bit or 64bit mode. 

The following Python script can be used to determine whether the Python shell is executing in 32bit or 64bit mode. The code was compiled successfully and it gave the result.



Method 1: Using Platform Packages

Here we are going to use platform packages to get the mode of or the os. architecture() methods from the platform packages return the mode of os.




import platform
print(platform.architecture())

Output

('64bit', '')

Method 2: Using  struct Packages

Struct package also helps to get the related mode of os.




import struct
print(struct.calcsize("P") * 8)

Output
64
Article Tags :