正则匹配整数或者小数 a = '15cm x 11cm x 4cm (5.91in x 4.33in x 1.57in)' s = re.findall('(d+|d.d+|0.d+)cm',a) print(s)