def is_float(s):
s = str(s)
if s.count(‘.‘) == 1:
left,right = s.split(‘.‘) #[1,1]#-s.2
if left.isdigit() and right.isdigit():
return True
elif left.startswith(‘-‘) and left.count(‘-‘)==1 \
and left[1:].isdigit() and right.isdigit():
return True
return False
原文:https://www.cnblogs.com/kangfei/p/14758280.html