不废话,直接上表达式
(\d+(\.\d+)?)
如:
1 import re 2 find_float = lambda x: re.search("\d+(\.\d+)?",x) .group() 3 find_float("有1.3元")
输出为:
'1.3'