def SubnetVerification(self, strTempSubNet):
"""
对输入的子网字符串进行校验
"""
# 对输入的交换机子网地址及子网掩码格式进行校验
if strTempSubNet.count('/') == 1:
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
strListNet = strTempSubNet.split('/')
if strListNet[0] != '' and strListNet[1] != '':
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
self.strIP = strListNet[0]
self.strSubMaskNum = strListNet[1]
# print(self.strIP)
# print(self.strSubMaskNum)
if 1 = int(self.strSubMaskNum, 10) = 32:
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
# 对输入的交换机子网地址进行校验
# 判断是否符合IP地址中有3个.
if self.strIP.count('.') == 3:
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
strList = self.strIP.split(".")
# print(strList)
if strList[0] != '' and strList[1] != '' and strList[2] != '' and strList[3] != '':
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
nList = list(map(int, strList))
if 0 = nList[0] = 255 and 0 = nList[1] = 255 and 0 = nList[2] = 255 and 0 = nList[3] = 255:
pass
else:
# 警告信息框
win32api.MessageBox(0, "请输入正确的子网,例:192.168.60.1/24", "温馨提示", win32con.MB_ICONWARNING)
return False
return True
到此这篇关于PyQt5 QLineEdit输入的子网字符串校验QRegExp实现的文章就介绍到这了,更多相关PyQt5 QLineEdit校验QRegExp内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!