def is_float(s):
s = str(s).strip()
if s.count('.') == 1:
left, right = s.split('.')
if left.isdigit() and right.isdigit(): # 正小数
return True
# 负小数
elif left.startswith('-') and left.count('-') == 1 and\
left.split('-')[-1].isdigit() and right.isdigit():
return True
return False
print(is_float('-.1'))
print(is_float('5.1'))
print(is_float('5.q'))
print(is_float('5.q.1'))
print(is_float('-5.1'))
print(is_float('--5.1'))
print(is_float('-a.1'))
print(is_float('.1'))
print(is_float('a.1'))
print(is_float('a12'))
print(is_float('2..22-5.6'))