This article mainly introduces Python to determine whether it is a positive decimal and positive integer instances of the relevant data, here provides examples, examples of annotations are clear, the need for friends can refer to the following
Python determines whether an instance of a positive decimal and a positive integer
Implementation code:
def check_float (string): #支付时, the amount entered may be a decimal or an integer s = str (string) if S.count ('. ') = = 1: # Determine the number of decimal points SL = S.split ('. ') # Splits by decimal point left = sl[0] # before the decimal point right = sl[1] # After the decimal point if Left.startswith ('-') and Left.count (' -') = = 1 and Right.isdigit (): lleft = Left.split ('-') [1] # Follow-split, then take the number after the minus sign if Lleft.isdigit (): return False elif Left.isdigit () and Right.isdigit (): # Determines whether a positive decimal return True elif s.isdigit (): s = Int (s) if s! = 0: return True return False