socket 获取局域网IP地址

import socket

host_name = socket.gethostname()
ip = socket.gethostbyname(host_name)
print("本地IP地址是:" + ip)

 

posted @ 2021-09-20 14:32  CodeYaSuo  阅读(326)  评论(0编辑  收藏  举报