我如何检测是否Python的运行为64位应用程序? [英] How do I detect if Python is running as a 64-bit application?

查看:204
本文介绍了我如何检测是否Python的运行为64位应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/1405913/how-do-i-determine-if-my-python-shell-is-executing-in-32bit-or-64bit-mode">How我确定我的蟒蛇壳正在执行的32位或64位模式?

我在做与Windows注册表中的某些工作。根据您是否正在运行Python作为32位或64位的密钥值会有所不同。如何检测,而不是一个32位应用程序,如果Python的运行为64位应用程序?

注:我没有兴趣在检测的32位/ 64位Windows - 只是Python的平台

解决方案

 进口平台
platform.architecture()
 

Python文档

  

查询给定的可执行文件(默认   为Python的跨preTER二进制)   不同体系结构的信息。

     

返回一个元组(比特,联动),其   包含有关比特信息   架构和联动格式   用于可执行文件。这两个值   返回字符串。

Possible Duplicate:
How do I determine if my python shell is executing in 32bit or 64bit mode?

I'm doing some work with the windows registry. Depending on whether you're running python as 32-bit or 64-bit, the key value will be different. How do I detect if Python is running as a 64-bit application as opposed to a 32-bit application?

Note: I'm not interested in detecting 32-bit/64-bit Windows - just the Python platform.

解决方案

import platform
platform.architecture()

From the Python docs:

Queries the given executable (defaults to the Python interpreter binary) for various architecture information.

Returns a tuple (bits, linkage) which contain information about the bit architecture and the linkage format used for the executable. Both values are returned as strings.

这篇关于我如何检测是否Python的运行为64位应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆