题解 | #合法IP#
合法IP
https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
while True: try: str1 = input().split(".") flag = 0 if len(str1) == 4: for i in str1: if (len(i) > 1 and i[0] != '0') or len(i) == 1: if i.isdigit() and 0 <= int(i) <= 255: flag += 1 if flag == 4: print('YES') else: print('NO') except: break