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()

打印内容:

相关推荐
huisheng_qaq8 分钟前
【Python基础篇-05】深入理解python的异常处理与文件读写
python·异常处理·文件读写
Zhou14113611 分钟前
SpringMVC_02_注解开发实战
开发语言·windows·python
禹凕30 分钟前
机器学习之数据清洗(Machine Learning about Data Cleaning)
人工智能·爬虫·python·机器学习·数据挖掘
浩瀚地学32 分钟前
deepagents学习打卡day07
经验分享·笔记·python·学习·agent
霸道流氓气质41 分钟前
Mermaid 图表完全指南:从文本语法到LangGraph4j工作流可视化实战
开发语言·python
SamChan9044 分钟前
PDF翻译时页眉页脚总在捣乱?跨页重复文本块的检测与过滤实测
人工智能·python·ai·pdf·wpf
晴空蓝天1 小时前
MDC traceId 全链路日志追踪:Spring Boot 3.5 里把日志串成一条线
java·spring boot·后端·python
L@ncor1 小时前
第六章可能出现的问题:依赖冲突与成本乘法
python·依赖管理·langgraph·agentscope·避坑
AC赳赳老秦1 小时前
财报附注表格精准提取:OpenClaw 从 PDF 年报附注挖掘隐藏明细,补齐财务分析维度
java·汇编·c++·python·青少年编程·deepseek·openclaw
小小张说故事1 小时前
CatBoost 入门指南:类别特征为什么不用 One-Hot?Python 实战与 5 个坑
python·机器学习