我正在尝试找到一种可移植的方式来收集当前的架构(例如x86_64
or AArch64
)我将用它来填充一个标志,例如is_x86
,使用Python 3。
它看起来像import platform; platform.machine()
函数是正确的,但它给了我不同的字符串,最终代表相同的(广义上)底层架构:
在 Linux x86_64 上:
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform; platform.machine()
'x86_64'
Windows x86_64:
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
>>> import platform; platform.machine()
'AMD64'
MacOS x86_64:
Python 3.7.7 (default, Mar 10 2020, 15:43:33)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform; platform.machine()
'x86_64'
还有i386
这是在 x86(32 位)系统上报告的。
有没有其他方法可以以可移植的方式可靠地收集架构?