判断浮点数

def is_float(s):
s=str(s)
if s.count(".")==1:
s_list=s.split(".")
left=s_list[0]
right=s_list[1]
if left.startswith("-") and left[1:].isdigit() and right.isdigit():
return True
elif left.isdigit() and right.isdigit():
return True
return False
print(is_float(+8.0))
原文地址:https://www.cnblogs.com/pengwa1226/p/9433728.html