首页 > 配置land-leg-PY是出错

配置land-leg-PY是出错

  部分代码
     def get_linux_mac(ifname):
    import struct
    import fcntl
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    info = fcntl.ioctl(s.fileno(), 0x8927,  struct.pack('256s', ifname[:15]))
    return ':'.join(['%02x' % ord(char) for char in info[18:24]])

def get_ip():
    if platform.system() == "Windows":
        ipList = socket.gethostbyname_ex(socket.gethostname())
        for i in ipList[2]:
            if i.split('.')[0] == "10":
                return i
    return get_linux_ip(eth_name)

def get_mac():
    if platform.system() == "Windows":
        import uuid
        mac=uuid.UUID(int = uuid.getnode()).hex[-12:] 
        return "-".join([mac[e:e+2] for e in range(0,11,2)]).upper()
    return get_linux_mac(eth_name).upper()

clientip = get_ip()
mac = get_mac()
print "Your IP: " + clientip
print "Your MAC: " + mac
print '-------------------------------------------'
  报错信息
  File "/Users/chenkuntao/Downloads/land-leg-PY-master/land_legX_m_login.py", line 72, in <module>
    mac = get_mac()
  File "/Users/chenkuntao/Downloads/land-leg-PY-master/land_legX_m_login.py", line 69, in get_mac
    return get_linux_mac(eth_name).upper()
  File "/Users/chenkuntao/Downloads/land-leg-PY-master/land_legX_m_login.py", line 53, in get_linux_mac
    info = fcntl.ioctl(s.fileno(), 0x8927,  struct.pack('256s', ifname[:15]))
IOError: [Errno 6] Device not configured
【热门文章】
【热门文章】