首页 > 编程语言 > 详细

Python判断是否为小数

时间:2021-05-12 10:07:50      阅读:12      评论:0      收藏:0      [点我收藏+]
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

Python判断是否为小数

原文:https://www.cnblogs.com/kangfei/p/14758280.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!