python-正则表达试-实践1

匹配html标签中的任意标签内数据

  1. 匹配所有包含'oo'的单词

    python 复制代码
    import re
    text = "JGood is a handsome boy, he is cool, clever, and so on..."
    re.findall(r'\w*oo\w*', text) 
  2. 匹配 html中title里面的内容

    原文:

python 复制代码
import re
file = r'./202304.html'
f = open(file,'r',encoding='utf-8')
origin_content = f.read()
#r'<title>(.*)</title>'  效果一样
result = re.findall(r'<title>(.*?)</title>',origin_content)
print(result)
f.close()

打印内容:

相关推荐
用户67570498850221 小时前
再见 pip!Rust 写的 uv 正在把 Python 包管理按在地上摩擦
后端·python
川石课堂软件测试21 小时前
接口测试常见面试题及答案
python·网络协议·mysql·华为·单元测试·prometheus·harmonyos
竹叶青lvye21 小时前
Python订阅与发布功能简介
python·订阅与发布
用户67570498850221 小时前
Python 装饰器很难?那是你没看到这篇文章!
后端·python
码界筑梦坊21 小时前
124-基于Python的航空旅客满意度数据可视化分析系统
开发语言·python·信息可视化·数据分析·flask·毕业设计
星越华夏21 小时前
PPTX判断包含图表id
python·pandas
梦想不只是梦与想21 小时前
Python 中的流程控制语句
python·流程控制·循环·条件判断·if
dinl_vin21 小时前
FastAPI 系列(一)· 初体验——从 Spring Boot 工程师视角认识 FastAPI
后端·python·fastapi
AI玫瑰助手21 小时前
Python流程控制:pass语句的作用与使用场景
开发语言·python·信息可视化
Metaphor69221 小时前
使用 Python 设置 Word 文档文本的颜色
python·word