wxTextCtrl을 구성했으며 사용자가 한 자릿수 만 입력하면 true를 반환하려고합니다. 내 isAllDigits 방법은 숫자 만이 감지되지 않았 어떤 이유wxTextCtrl 파이썬에서만 숫자를 탐지하는 코드
if self.firstNum.IsEmpty() or not self.isAllDigits(self.firstNum.GetValue()):
self.dataInputIsValid = False
msgStr = "Your first number is invalid, please enter only enter digits and do not leave the field blank."
wx.MessageBox(msgStr)
if self.secondNum.IsEmpty() or not self.isAllDigits(self.secondNum.GetValue()):
self.dataInputIsValid = False
msgStr = "Your second number is invalid, please enter only enter digits and do not leave the field blank."
wx.MessageBox(msgStr)
:
@staticmethod
def isAllDigits(s):
for char in list(s):
if not char.isdigit():
return False
else:
break
return True
그리고 내 코드 isAllDigits를 호출
여기 내 파이썬 코드입니다. 예를 들어, textCtrl에 "3k5"를 입력하면 내 프로그램은 "3k5"가 모든 자릿수이고 올바르지 않은 것을 반환합니다. 이는 잘못된 것입니다.
isAllDigits 메소드의 문제점은 무엇입니까?
else break를 삭제 –