题解 | #合法IP#
合法IP
http://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
while True:
try:
N = str(input())
ls = N.split(".")
state = "YES"
if len(ls) != 4:
state = "NO"
for i in ls:
if i=="":
state = "NO"
continue
if i.startswith('0') and len(i) > 1:
state = "NO"
continue
if not i.isdigit():
state = "NO"
continue
if int(i) < 0:
state = "NO"
continue
if int(i) > 255:
state = "NO"
continue
print(state)
except:
break