获取本机的IP地址和mac地址

1. 之前一直用ipconfig来查看ip地址,哈哈哈,如今发现挺好玩html

#获取本机的IP地址和mac地址
import uuid
import socket

def get_mac_address(): 
    mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
    #print(mac)
    return ":".join([mac[e:e+2] for e in range(0,11,2)]) #range(0,11,2):在[0:11]取值,间隔为2

def get_ip_address():
    host_name = socket.getfqdn(socket.gethostname())
    ip_address = socket.gethostbyname(host_name)
    return host_name, ip_address

if __name__ == '__main__':
    mac_address = get_mac_address()
    print('the mac address is: '+mac_address)
    ip_address = get_ip_address()
    print('the host name is: '+ip_address[0])
    print('the ip address is: '+ip_address[1])

2. adb查看手机设备信息,参考:https://blog.csdn.net/weixin_43927138/article/details/90477966https://www.jianshu.com/p/7c0a6da594c8node

上述方法我试过了,配置好adb以后:socket

# 在命令行:cmd下使用
# 第一次连上设备时,使用:
adb devices
# 能够显示设备,以后就不行了,而后再次使用时一直显示:List of devices attached
# 我的以为是设备的调试开关出了问题,后来通过测试,确认是调试开关的问题,换了一个调试开关没问题的机器就能够了

参考:测试

http://www.javashuo.com/article/p-fkbeurne-d.htmlui

##记录笔记spa

相关文章
相关标签/搜索