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

打印内容:

相关推荐
2601_9669496515 小时前
批量 K 线不只是提速:因子研究中的数据质量、复权与回测偏差
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
一位正在转型AI全栈的前端工程师15 小时前
AI 全栈学习之旅 -Week 11:从 CLI 到浏览器:用 FastAPI、SSE 和 Vue 3 做一个可审核的 ReAct Agent
前端·python
洛阳纸贵16 小时前
AI-PyTorch(一)基础代码实操和自动求导
人工智能·pytorch·python
2601_9622845016 小时前
uv:终结 Python 虚拟环境管理乱局
python·项目管理·uv·虚拟环境·依赖管理
Patrick在香港16 小时前
Claude + Python 数据管道:一次字段改名,786 行历史数据被静默重写
开发语言·windows·python·claude·数据工程·数据校验·数据管道
the局外人16 小时前
学习 FastAPI 的 Day 3:企业级目录与数据库迁移
后端·python·fastapi
Ray133316 小时前
交付级定时数据管道:改 JSON 声明调度,84 个单测全绿
python
mldong16 小时前
AI Agent 不能自己签字:用 Python 工作流引擎给 AI 加一道人类审批闸门
后端·python·agent
青少儿编程课堂16 小时前
贪心算法进阶:区间调度与最少资源整合解析
c++·python·算法·贪心·信息学竞赛·区间调度
Yanjun2i16 小时前
Agent学习记录六:Tool 类 + Tool Registry
开发语言·python·学习