QQmini
import socket

def get_host_ip():
    """
    查询本机ip地址
    :return:
    """
    try:
        s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        s.connect((\'8.8.8.8\',80))
        ip=s.getsockname()[0]
    finally:
        s.close()
    return ip
if __name__ == \'__main__\':
    print(get_host_ip())

 

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-07-26
  • 2021-11-17
猜你喜欢
  • 2021-11-05
  • 2022-12-23
  • 2021-12-05
  • 2021-12-15
相关资源
相似解决方案