码迷,mamicode.com
首页 > 其他好文 > 详细

字符串中匹配数字

时间:2017-02-22 18:15:36      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:color   span   alt   code   ber   int   6.4   多个   number   

import re

string="A1.45,b5,6.45,8.82"
print(re.findall(r"\d+\.?\d*",string))  # r"\d+\.?\d*"  \d+ 匹配一个或多个数字; \.? 匹配.一次或零次; \d* 匹配零个或多个数字
# [‘1.45‘, ‘5‘, ‘6.45‘, ‘8.82‘]

 

 

字符串中匹配数字

标签:color   span   alt   code   ber   int   6.4   多个   number   

原文地址:http://www.cnblogs.com/cymwill/p/6430069.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!