69,373
社区成员
发帖
与我相关
我的任务
分享
f= ('-555', '0555', '-0.1', '0.1212', '0', '0.0')
import re
integer = r'^[+-]?[^0]\d+'
faction = r'^[+-]?\d+\.\d*[1-9]+'
mat = integer+'|'+faction
patt0 = re.compile(mat)
for each in f:
print each,
result = patt0.match(each)
if result is not None: print 'OK'
else: print '-'