CPU Architecture
In Python, the platform module provides many methods for obtaining operating system information. The following lists the common information code examples:
import platform
print(platform.platform()); # Obtains the operating system name and version number.
print(platform.version()); # Obtains the operating system version number.
print(platform.architecture()); # Obtains the operating system architecture ('64bit', 'ELF').
print(platform.machine()); # Obtains the computer type, 'aarch64'.
print(platform.node()); # Obtains the network name of the computer.
print(platform.processor()); # Obtains the computer processor information, 'aarch64'.
print(platform.uname()); # Obtains all the preceding information.
Execution result on the Kunpeng platform:
[root@centos7 test]# python test.py
Linux-4.14.0-115.el7a.0.1.aarch64-aarch64-with-centos-7.6.1810-AltArch
#1 SMP Sun Nov 25 20:54:21 UTC 2018
('64bit', 'ELF')
aarch64
centos7
aarch64
('Linux', 'centos7', '4.14.0-115.el7a.0.1.aarch64', '#1 SMP Sun Nov 25 20:
54:21 UTC 2018', 'aarch64', 'aarch64')
Parent topic: Python