def is_number(num): ''' 判断是否为数字 :param num: :return: ''' pattern = re.compile(r'^[-+]?[-0-9]\d*\.\d*|[-+]?\.?[0-9]\d*$') result = pattern.match(str(num)) if result: return True else: return False print(is_number('232.323')) print(is_number('232')) print(is_number('0.2e-5')) print(is_number(334.34)) print(is_number(334)) print(is_number('-33.33')) print(is_number('-33')) print(is_number('-0.2e-5')) print(is_number('fsd.2'))
python 判断是否为数字
猜你喜欢
转载自www.cnblogs.com/snailgirl/p/12228729.html
今日推荐
周排行