【问题标题】:What does platform.system() and platform.architecture() return on Apple M1 Silicon?什么 platform.system() 和 platform.architecture() 在 Apple M1 Silicon 上返回?
【发布时间】:2021-05-04 07:36:40
【问题描述】:

我没有可以使用的 M1 Mac,我读到 python 支持它。这些功能在 m1 Mac 上的回报是什么?

platform.system()
platform.architecture()

谢谢。

【问题讨论】:

标签: python-3.x architecture system apple-silicon


【解决方案1】:

在实际的 M1 Mac 上,platform 模块返回以下值:

shuuji3@momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:03)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-arm64-arm-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'arm'

除此之外,在 Rosetta 2(Intel 模式)下,platform 模块返回以下内容:

(注意:对于第一个命令,我按照文章中的说明进行操作,How to Run Legacy Command Line Apps on Apple Silicon | Walled Garden Farmers。)

shuuji3@momo ~ % env /usr/bin/arch -x86_64 /bin/zsh --login
shuuji3@momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:04)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-x86_64-i386-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'i386'

我们可以用来区分当前M1 mac使用的模式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 2022-01-10
    • 1970-01-01
    • 2022-01-22
    • 2021-03-02
    • 2021-08-30
    • 2021-04-21
    相关资源
    最近更新 更多