Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

validate ip address python

def validate_ip(ip_address):
    octets = ip_address.split(".")
    if len(octets) != 4:
        # String is not an ip address if there are not 4 octets
        return False
    for num in octets:
        if not num.isdigit():
            # String is not an ip address if there are non-digits in it
            return False
        n = int(num)
        if n < 0 or n > 255:
            # String is not an ip address if an octet is less than 0 or greater than 255
            return False
    return True
Comment

PREVIOUS NEXT
Code Example
Python :: appending to a file in python 
Python :: python plotting moving average 
Python :: numpy array length 
Python :: esp8266 micropython ds18b20 
Python :: python add item multidimensional list 
Python :: Double-Linked List Python 
Python :: python convert string to bytes 
Python :: show equation using geom_smooth 
Python :: list comprehension python if 
Python :: python list divide 
Python :: Python pandas first and last element of column 
Python :: how to create model in tensorflow 
Python :: get month day year 12 hour time format python 
Python :: how to find last index of list in python 
Python :: python efficiently find duplicates in list 
Python :: python fillna with mean in a dataframe 
Python :: how to make a distance function in python 
Python :: Get files from S3 bucket Python 
Python :: flask port 
Python :: clone website 
Python :: remove last line of text file python 
Python :: create a blank image 
Python :: strip first occurence of substring python 
Python :: dict typing python 
Python :: random library python 
Python :: sort columns dataframe 
Python :: python slicing nested list 
Python :: program to print duplicates from a list of integers in python 
Python :: print list in python 
Python :: replace none with empty string python 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =