def looks_like_ip(maybe_ip):
    if not maybe_ip[0].isdigit():
        return False

    try:
        socket.inet_aton(maybe_ip)
        return True
    except (AttributeError, UnicodeError):
        if IP_RE.match(maybe_ip):
            return True
    except socket.error:
        return False
Does the given str look like an IP address?
dataset/ETHPy150Open john-kurkowski/tldextract/tldextract/remote.py/looks_like_ip