Python determines whether the instance is a positive decimal or a positive integer, and python decimal
Python determines whether an instance is a positive decimal or a positive integer.
Implementation Code:
Def check_float (string): # The input amount may be decimal or integer s = str (string) if s. count ('. ') = 1: # determine the number of decimal places sl = s. split ('. ') # split by decimal point left = sl [0] # right Before decimal point = sl [1] # if left after decimal point. startswith ('-') and left. count ('-') = 1 and right. isdigit (): lleft = left. split ('-') [1] # split by-, and then take the number after the minus sign if lleft. isdigit (): return False elif left. isdigit () and right. isdigit (): # determines whether the return True elif s is a positive decimal. isdigit (): S = int (s) if s! = 0: return True return False
The above is a detailed explanation of whether python determines whether it is a positive decimal point or a positive integer. There are many articles related to python on this site. I hope you can search for them and thank you for reading them. I hope they can help you, thank you for your support!