题解 | #合法IP#
合法IP
http://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
while True:
try:
nums = input().split('.')
if len(nums) != 4:
print('NO')
continue
count = 0
for n in nums:
if not n.isdigit():
print('NO')
break
else:
if int(n) > 255:
print('NO')
break
else:
count += 1
if count == 4:
print('YES')
except:
break
查看5道真题和解析