有没有可靠的方法使用 Python 确定系统 CPU 架构? [英] Is there a reliable way to determine the system CPU architecture using Python?

查看:40
本文介绍了有没有可靠的方法使用 Python 确定系统 CPU 架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能的重复:
如何在 Python 中返回系统信息?

例如,查看 Solaris 是 Solaris X86 还是 Solaris SPARC?

解决方案

我使用了以下内容:

<预><代码>>>>进口平台>>>平台.uname()(达尔文"、马修-兰金斯-MacBook-Pro.local"、10.8.0"、'达尔文内核版本 10.8.0:2011 年 6 月 7 日星期二 16:32:41 PDT;根:xnu-1504.15.3~1/RELEASE_X86_64', 'x86_64', 'i386')>>>

来自 Python 平台文档:

<块引用>

platform.uname()

相当便携的uname界面.返回标识底层平台的字符串元组(系统、节点、发布、版本、机器、处理器).

请注意,与 os.uname() 函数不同,这也将可能的处理器信息作为附加元组条目返回.

无法确定的条目设置为''.

Possible Duplicate:
How can I return system information in Python?

For example, to see if a Solaris is a Solaris X86 or Solaris SPARC?

解决方案

I used the following:

>>> import platform
>>> platform.uname()
('Darwin', 'Matthew-Rankins-MacBook-Pro.local', '10.8.0', 
'Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; 
root:xnu-1504.15.3~1/RELEASE_X86_64', 'x86_64', 'i386')
>>> 

From the Python platform documentation:

platform.uname()

Fairly portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) identifying the underlying platform.

Note that unlike the os.uname() function this also returns possible processor information as additional tuple entry.

Entries which cannot be determined are set to ''.

这篇关于有没有可靠的方法使用 Python 确定系统 CPU 架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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