platform.system() 和 platform.architecture() 在 Apple M1 芯片上返回什么?

时间:2021-01-30 16:39:22

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

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

ImageView imageView = params[0];
imageView.setImageResource(R.drawable.myNewImage);
return imageView;

谢谢。

1 个答案:

答案 0 :(得分:0)

在实际的 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使用的模式。