Python determines whether a Windows system is a 32-bit or 64-bit method

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.