import platform import os import sys import platform def machine(): """Return type of machine.""" if os.name == 'nt' and sys.version_info[:2] < (2,7): return os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get('PROCESSOR_ARCHITECTURE', '')) else: return platform.machine() def os_bits(machine=machine()): """Return bitness of operating system, or None if unknown.""" machine2bits = {'AMD64': 64, 'x86_64': 64, 'i386': 32, 'x86': 32} return machine2bits.get(machine, None) if __name__ == '__main__': print(platform.machine()) print(platform.node()) print(platform.platform(True)) print(platform.system()) print(platform.uname()) print(platform.architecture()[0]) print(platform.platform() + ' ' + platform.architecture()[0]) print (os_bits())
输入内容可能如下:
i686
localhost.localdomain
Linux-3.12.11-201.nk.1.i686.PAE-i686-with-redhat-6.0
Linux
('Linux', 'localhost.localdomain', '3.12.11-201.nk.1.i686.PAE', '#1 SMP Sun Jun 8 19:40:47 CST 2014', 'i686', 'i686')
32bit
Linux-3.12.11-201.nk.1.i686.PAE-i686-with-redhat-6.0 32bit
None
- 微信扫码赞助
- 支付宝赞助