20 lines
336 B
Python
20 lines
336 B
Python
import re
|
|
import sys
|
|
|
|
|
|
def main():
|
|
print(validate(input("IPv4 Address: ")))
|
|
|
|
|
|
def validate(ip):
|
|
if not re.match(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', ip):
|
|
return False
|
|
for n in map(int, ip.split('.')):
|
|
if not 0 <= n <= 255:
|
|
return False
|
|
return True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|