微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

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

谢谢。

解决方法

在实际的 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,15:06:04)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help","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使用的模式。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。