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

打印内容:

相关推荐
nimadan126 分钟前
手机制作AI漫剧APP2025推荐,高效便捷创作体验
人工智能·python·智能手机
kronos.荒9 分钟前
柱状图中的最大矩形(python)
python·单调栈
学而要时习10 分钟前
强化学习:从“试错进化“到“推理革命
c语言·人工智能·python·语言模型
June bug10 分钟前
(Mac)docling-mcp 的依赖解析器找不到匹配的 torch 安装包
经验分享·python·macos
小陈工10 分钟前
2026年4月1日技术资讯洞察:AI芯片革命、数据库智能化与云原生演进
前端·数据库·人工智能·git·python·云原生·开源
芜湖xin10 分钟前
【解决Error】pip安装Flask失败
python·flask·pip
m0_7471245311 分钟前
LangChain 嵌入向量详解
python·ai·langchain
迷藏49415 分钟前
**发散创新:Go语言中基于上下文的优雅错误处理机制设计与实战**在现代后端开发中,**错误处理**早已不是简单
java·开发语言·后端·python·golang
2301_7644413315 分钟前
基于python实现的便利店投资分析财务建模评估
开发语言·python·数学建模
Chase_______28 分钟前
【Python 基础】第4章:函数模块与包完全指南(函数/模块/包)
开发语言·python