def SubnetVerification(self, strTempSubNet):
"""
對輸入的子網(wǎng)字符串進行校驗
"""
# 對輸入的交換機子網(wǎng)地址及子網(wǎng)掩碼格式進行校驗
if strTempSubNet.count('/') == 1:
pass
else:
# 警告信息框
win32api.MessageBox(0, "請輸入正確的子網(wǎng),例:192.168.60.1/24", "溫馨提示", win32con.MB_ICONWARNING)
return False
strListNet = strTempSubNet.split('/')
if strListNet[0] != '' and strListNet[1] != '':
pass
else:
# 警告信息框
win32api.MessageBox(0, "請輸入正確的子網(wǎng),例: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, "請輸入正確的子網(wǎng),例:192.168.60.1/24", "溫馨提示", win32con.MB_ICONWARNING)
return False
# 對輸入的交換機子網(wǎng)地址進行校驗
# 判斷是否符合IP地址中有3個.
if self.strIP.count('.') == 3:
pass
else:
# 警告信息框
win32api.MessageBox(0, "請輸入正確的子網(wǎng),例: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, "請輸入正確的子網(wǎng),例: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, "請輸入正確的子網(wǎng),例:192.168.60.1/24", "溫馨提示", win32con.MB_ICONWARNING)
return False
return True
到此這篇關(guān)于PyQt5 QLineEdit輸入的子網(wǎng)字符串校驗QRegExp實現(xiàn)的文章就介紹到這了,更多相關(guān)PyQt5 QLineEdit校驗QRegExp內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!