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

打印内容:

相关推荐
mingshili8 小时前
[Python] Python中自带模块级的单例模式-不需要定义单例类
python·单例模式
alphaTao8 小时前
LeetCode 每日一题 2026/5/18-2026/5/24
python·leetcode
徐安安_ye18 小时前
FlashAttention学习路线:从调API到写算子,你该走哪条路
python·学习
IT策士9 小时前
Django 从 0 到 1 打造完整电商平台:商品搜索
后端·python·django
茉莉玫瑰花茶9 小时前
LangGraph 持久化(Persistence)[ 2 ]
开发语言·python·ai·langgraph
有味道的男人9 小时前
AI 对接 1688 图搜接口|Open Claw 以图搜货实战
开发语言·python
MediaTea9 小时前
DL:Transformer 的基本原理与 PyTorch 实现
人工智能·pytorch·python·深度学习·transformer
wuxinyan1239 小时前
工业级大模型学习之路024:LangChain零基础入门教程(第七篇):RAG 系统评估、全链路调优
人工智能·python·学习·langchain
Kingairy9 小时前
Python简单算法题
开发语言·python
SilentSamsara9 小时前
日志与可观测性:logging 进阶配置与结构化日志实战
运维·开发语言·python·青少年编程