python-3.x - 什么 platform.system() 和 platform.architecture() 在 Apple M1 Silicon 上返回?
问题描述
我没有可以使用的 M1 Mac,我读到 python 支持它。这些功能在 m1 Mac 上的回报是什么?
platform.system()
platform.architecture()
谢谢。
解决方案
在实际的 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
模块返回以下内容:
(注意:对于第一个命令,我按照文章如何在 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 使用的是哪种模式。
推荐阅读
- javascript - 附加到每个代理的列表?
- outlook - Outlook 约会的上下文 Outlook 加载项
- android - 颤动的简单文本示例
- sql-server - 使用 ASP.NET Core 3.0 和 SQL Server 2019+ 时,我应该何时使用 MultipleActiveResultSets=True?
- angular - ** ionic build --prod** build 给出 FATAL ERROR: Ineffective mark-compacts near heap limit 分配失败 - JavaScript 堆内存不足
- git - 如何在没有历史记录的情况下将 git 存储库从一个远程移动到另一个?
- c++ - 为 Android NDK 编译库
- sql - 如何制作一个从 SQL 表中读取并修改它们的脚本?
- spring - 未触发特定异常的 RetryTemplate
- json - 如何查询sqlite json1