Varsha Bolli
Varsha Bolli

Reputation: 57

How can i detect whether my os is 32 bit or 64 bit through python code

I want to know the system type(os) through python code. I have tried platform.architecture() which returns 32 bit, Windows PE as my os is 64-bit.

If system type(os) is 32-bit what it will return ?

Thanks in advance!

Upvotes: 2

Views: 169

Answers (1)

Nitheesh MN
Nitheesh MN

Reputation: 628

import platform
platform.architecture()
  ('32bit', 'WindowsPE')

On 64-bit Windows, 32-bit Python returns:

 ('32bit', 'WindowsPE') # Don't know why.

A good method is to write a function like

def check_os_type():
    if platform.machine().endswith('64'):
        return '64 bit'
    if  platform.machine().endswith('32'):
        return '32 bit'

Upvotes: 2

Related Questions