python-3.x - 如何通过python代码检测我的操作系统是32位还是64位

标签 python-3.x

我想通过python代码了解系统类型(os)。 我尝试过 platform.architecture() ,它返回 32 位,Windows PE,因为我的操作系统是 64 位。

如果系统类型(os)是32位,它将返回什么?

提前致谢!

最佳答案

import platform
platform.architecture()
  ('32bit', 'WindowsPE')

在 64 位 Windows 上,32 位 Python 返回:

 ('32bit', 'WindowsPE') # Don't know why.

一个好的方法是编写一个类似的函数

def check_os_type():
    if platform.machine().endswith('64'):
        return '64 bit'
    if  platform.machine().endswith('32'):
        return '32 bit'

关于python-3.x - 如何通过python代码检测我的操作系统是32位还是64位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50214255/

相关文章:

python - 有没有一种方法可以查明Python线程锁是否被多个线程使用过?

python - 在Python 3.6中验证JSON,其中内部blob的数量是可变的?

python-3.x - 使用 predict_signature_def 保存 keras 多输入模型的签名

Python3 与 asyncpg 的语法错误

python - CosmosDB 和 Python3 : how to query?

python - 使用 Python tpot 配置 njobs

python3 ModuleNotFound

Python - 如何在不一次将整个文件加载到内存的情况下发送带附件的电子邮件?

python - 尝试使用 pandas 进行 pytest 测试时出现 Keyerror

python - 在AWS EC2实例中加载pickle包