"""
練習判斷一個小數
1、判斷是否合法
2、合法需要有一個小數點
3、小數點左邊必須是個整數,右邊必須是個正整數
"""
def xiaoshu(s):
xiaoshu_new=str(s)
if xiaoshu_new.count(".") ==1:
left,right = xiaoshu_new.split(".")
if left.isdigit() and right.isdigit():
print(1111)
return True
elif left.startswith('-') and left.count('-') == 1 and right.isdigit():
lleft = left.split('-')[-1]
if lleft.isdigit():
return True
return False
a = xiaoshu(-.1)
print(a)