You can download this code by clicking the button below.
This code is now available for download.
This function is used to get the IP address of a specified host. If the hostname cannot be resolved, it returns None.
Technology Stack : socket
Code Type : Network programming
Code Difficulty : Intermediate
import math
import os
import random
import re
import socket
import sys
def find_ip_address(host):
"""
获取指定主机的IP地址
"""
try:
return socket.gethostbyname(host)
except socket.gaierror:
return None