python正则匹配

两种方法 :

str='价格 ¥ 198.00'
mode = re.compile(r'(([0-9]+)(.[0-9]{1,2})?)')
print mode.findall(str)[0][0]

2
tmp=re.search(r'(([0-9]+)(.[0-9]{1,2})?)',str).group()
结果都是198.00


posted @ 2017-07-01 20:46  xqnq2007  阅读(155)  评论(0编辑  收藏  举报