判断浮点数

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))

posted on 2018-08-06 21:59  smileBB  阅读(241)  评论(0编辑  收藏  举报