我第一次来这里,有一个问题请教:
我想检查用户在输入 ipv4 时是否输入如果不是 ipv4 用户应该收到 3 次错误然后退出。我的示例代码如下:
# Hosts and Commands
for attempt in range(3):
host = input("Enter IPs separated by SPACE: ")
cmd = input("Enter Command(s) seperated by ',' : ")
if(len(host) != 0) and (len(cmd) != 0):
break
print("Fields Cannot be Blank, try again...")
else:
Screen().input("Sorry...Execution Terminated, Press [ENTER] to Exit")
return