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

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

问题描述

可能的重复:
怎么做我确定我的 python shell 是在 32 位还是 64 位模式下执行?

我正在处理 Windows 注册表.根据您以 32 位还是 64 位运行 python,键值会有所不同.如何检测 Python 是作为 64 位应用程序运行还是作为 32 位应用程序运行?

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?

注意:我对检测 32 位/64 位 Windows 不感兴趣 - 只是 Python 平台.

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

推荐答案

import platform
platform.architecture()

来自 Python 文档:

查询给定的可执行文件(默认值到 Python 解释器二进制文件)各种架构信息.

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天全站免登陆