Cómo verificar si Windows es de 32 o 64 bits en Python2.2

In python2.7 it's simple, just import the lib platform. But how can i see if my windows is 32 or 64 bits? I work with a system build in python2.2 and can't find a way of do that :(

Alguna sugerencia?

preguntado el 31 de julio de 12 a las 15:07

Just out of curiosity, why are you using Python 2.2? It's more than 10 years old and the new versions are as free as the old ones. -

@MartijnPieters: that checks whether the interpreter was built in 32-bits or 64-bits mode. It doesn't tell you much about the OS. -

:/ Because i work in a company that still use the python2.2 on our major application, i know it's sucks :/. @larsmans -

@larsmans: you puede have a 32-bit python interpreter on a 64-bit platform, but you cannot make that work the other way around. Thus, the two usually correlate. -

2 Respuestas

La opción platform módulo código fuente es informativo.

Backported from there to determine the machine architecture on a Windows platform, it would use:

import os

def machine():
    try:
        return os.uname()[-1]
    except AttributeError:
        if "PROCESSOR_ARCHITEW6432" in os.environ:
            return os.environ.get("PROCESSOR_ARCHITEW6432", '')
        else:
            return os.environ.get('PROCESSOR_ARCHITECTURE', '')

Respondido 31 Jul 12, 15:07

En Python 2.x puedes hacer esto:

import sys
print sys.maxint  

And detect if it's 32/64 bit by sys.maxint.

Tenga en cuenta: this method may probably fail if you're running a 32 bit Python on a 64 bit machine.

Respondido el 20 de junio de 13 a las 23:06

Is that not dependent on the build of Python itself and not the OS? - Torre del cielo de Noctis

@NoctisSkytower Yes indeed. And I myself consider it as a well, can it be worse? respuesta. - estrellar

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.