This example describes how Python determines whether a Windows system is a 32-bit or 64-bit method. Share to everyone for your reference. The specific analysis is as follows:
Typically 64 of the Windows System Program Files folder (the default default directory used to install the application), there are 2, one is programs files and the other is Program Files (x86), while 32bit Files this one folder.
Based on this feature, we can determine whether the Windows system is 32 or 64 bits.
Import OSPRG = ' C:Program Files (x86) ' if True = = Os.path.exists (PRG): print ' 64bit ' else: print ' 32bit '
The above code is actually problematic, if the current system is installed in the D disk, then there is a problem, so in order to improve the above code can be judged by the current system installation letter, this can be from the system environment variables.
Another way to use environment variables directly:
ProgramFiles (X86) Import Osdef is64windows (): return ' ProgramFiles (X86) ' in Os.environ
The above function determines whether the current system is a 64bit system, and this method has no problem with the first method.
Hopefully this article will help you with Python programming.