商务合作加Q:411239339

python获取系统信息

浏览:258次阅读
没有评论

共计 1072 个字符,预计需要花费 3 分钟才能阅读完成。

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

正文完
扫码赞助
post-qrcode
 0
果子
版权声明:本站原创文章,由 果子 于2015-03-04发表,共计1072字。
转载说明:除特殊说明外本站文章皆由果较瘦原创发布,转载请注明出处。
评论(没有评论)