Erlo

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

2019-11-06 22:00:27 发布   308 浏览  
页面报错/反馈
收藏 点赞

1. 以前一直用ipconfig来查看ip地址,哈哈哈,现在发现挺好玩

#获取本机的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/7c0a6da594c8

参考:

https://www.cnblogs.com/chenjingyi/p/5741742.html

##记录笔记

登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认