platform — 访问底层平台的标识数据

源代码: Lib/platform.py


注意

具体平台按字母顺序列出,Unix 部分包含 Linux。

跨平台

platform. architecture ( executable = sys.executable , bits = '' , linkage = '' )

查询给定可执行文件 (默认为 Python 解释器二进制文件) 为各种体系结构信息。

返回元组 (bits, linkage) 其中包含可执行文件使用的位体系结构和链接格式的有关信息。两者值以字符串形式返回。

无法确定的值按预置参数给定方式返回。若 bits 给定为 '' sizeof(pointer) (或 sizeof(long) on Python version < 1.5.2) is used as indicator for the supported pointer size.

函数依赖系统 file command to do the actual work. This is available on most if not all Unix platforms and some non-Unix platforms and then only if the executable points to the Python interpreter. Reasonable defaults are used when the above needs are not met.

注意

On macOS (and perhaps other platforms), executable files may be universal files containing multiple architectures.

To get at the “64-bitness” of the current interpreter, it is more reliable to query the sys.maxsize 属性:

is_64bits = sys.maxsize > 2**32