1. 匹配字符串中的一个百分比数字
import re
t = 'yx is a very lovely girl. 5.568% company ltd.'
match = re.search(r"\d+\.\d*%", t)
print(match.group())
2.匹配小括号()里面的内容
# 这种方式的输出是列表类型, 不包含括号本身
import re
t = '(123, "345")' match = re.findall( r"[(](.*)[)]", t ) print(match)
3.匹配字符串中的一个数字
import re
t = '123 entity' match = re.search(r"\d+", t ) print(match.group())
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。