python-3.x - 如何通过 python 代码检测我的操作系统是 32 位还是 64 位
问题描述
我想通过python代码知道系统类型(os)。我尝试过返回 32 位的 platform.architecture(),Windows PE 因为我的操作系统是 64 位。
如果系统类型(操作系统)是 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'
推荐阅读
- html - 响应滚动的图像大小
- angular - angular - 在所有组件中共享模态
- mongodb - Docker + Mongodb:在 Dockerfile 中启动副本集
- python-3.x - TF:如果存在两个 GPU,内存分配错误
- pandas - 绘制熊猫数据框时缺少 xticklabels 的第一个值
- php - 不正确的响应 json 编码和数组冲突 Woocomerce 3
- scala - Slick/HikariCP/MySQL 总是超时
- python - 读取json文件时溢出错误
- mysql - 带有 Model::with 附加列的 laravel 问题
- mysql - 结合 2 个数据库(mySQL 和 Azure)