Skip to content

python看看

python看看为python程序员小家

  • 首页

python看看

python看看为python程序员小家

  • 首页
2023年 5月 26日

Python正则表达式匹配数字和小数

  • 未分类
  • admin

Python正则表达式匹配数字和小数

1、匹配数字

import re

str_date = 'hello world today is 2022.4.15 ok'
num_list = re.findall('\d+', str_date)
print('匹配到的数字', num_list)
  • 1
  • 2
  • 3
  • 4
  • 5

输出:

匹配到的数字 ['2022', '4', '15']
  • 1

2、匹配数字、小数点

    Copyright © 2022