Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Validate IP Address

try:
            if len(IP.split('.')) == 4:
                print(IP)
                if all([bool(1) if(str(int(s)) == s and 0 <= int(s) <= 255) else bool(0) for s in IP.split('.')]):
                    return "IPv4"
            if len(IP.split(':')) == 8:
                if all([bool(1) if(len(s) <= 4 and int(s, 16) >= 0) else bool(0) for s in IP.split(':')]):
                    return "IPv6"
        except:
            return "Neither"
        return "Neither"
Comment

PREVIOUS NEXT
Code Example
Python :: python turtle fill 
Python :: python delete all occurrences from list 
Python :: how to make a python terminal 
Python :: convert generator to list python 
Python :: how to make a dict from a file py 
Python :: get file size python 
Python :: pygame text wrapping 
Python :: Python Difference between two dates and times 
Python :: max of double array python 
Python :: linking bootstrap in flask 
Python :: convert string to lowercase in python 
Python :: create numpy array with ones 
Python :: inherit init method 
Python :: pandas insert row 
Python :: pandas currency to numbe 
Python :: tkinter responsive gui 
Python :: python binary search 
Python :: dataframe unstack 
Python :: django sample 
Python :: Python Frozenset operations 
Python :: prime numbers python 
Python :: associate keys as list to values in python 
Python :: plot data python 
Python :: webdriverwait python 
Python :: python pretty print list of tuples 
Python :: list length in python 
Python :: python machine learning scale 
Python :: Publish Image msg ros python 
Python :: pandas invert a boolean Series 
Python :: django model get field verbose name 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =