python 获取机器信息

python 功能很强大, 也是一门很容易学习的语言,这里介绍下用python 获取机器代码


直接贴代码来

#获取服务器信息


import urllib2

import socket

import platform

def getServerInfo(serverURL):

    '''根据域名获得服务器信息 (网络)

    测试:getServerInfo("http://163.com")

    '''

    try:

        sock = urllib2.urlopen(serverURL) 

        info = sock.headers.values() #可以知道远程服务器操作系统 ,网络等信息

        print info


    except Exception,err:

        print u"域名 不存在"

        return

def getLocalHostInfo():

    '''获得本地机器信息

    '''

    print u"操作系统名称及版本号: ",platform.platform()

    print u"操作系统的位数: ",platform.architecture()

    print u"计算机类型: ", platform.machine()

    print u"计算机的网络名称: ", platform.node()

    print u"计算机处理器信息: ", platform.processor()


转载于:https://my.oschina.net/u/247498/blog/224223

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值