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

打印内容:

相关推荐
爱昏羔12 分钟前
下篇:从检索到交互 — 物流RAG问答系统与WebUI全实现
python·langchain·agent
_Jimmy_20 分钟前
Agent引用数据库知识过时的增量同步方案
人工智能·python·langchain
min(a,b)2 小时前
学习第 4 天:面向对象与异常处理
python·学习·学习方法
yangshicong3 小时前
第19章:AI安全防护与AI安全
人工智能·python·安全·prompt·ai编程
果汁华3 小时前
Function Calling 与 Python 实战完整指南
开发语言·网络·python
c_lb72884 小时前
2026年不同基础做量化,先找AI能参与的位置
人工智能·python
chenment5 小时前
ComfyUI 自定义节点开发:从零扩展你的图像生成工作流
python·stable diffusion
IT空门:门主6 小时前
Python 基础语法学习路线图
网络·python·学习
互联网中的一颗神经元6 小时前
小白python入门 - 25. SQL 与表设计入门
数据库·python·sql
RSTJ_16258 小时前
PYTHON+AI LLM DAY ONE HUNDRED AND EIGHTEEN
python