python - 配置land-leg-PY是出错
伊谢尔伦
伊谢尔伦 2017-04-18 09:28:10
[Python讨论组]
  部分代码
     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
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号