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

打印内容:

相关推荐
珺毅同学8 分钟前
YOLO生成预测json标签迁移问题
python·yolo·json
骑士雄师22 分钟前
18.4 长期记忆可修改版
python
~小先生~39 分钟前
Python从入门到放弃(一)
开发语言·python
天佑木枫1 小时前
第2天:变量与数据类型 —— 让程序记住信息
python
Dust-Chasing2 小时前
Claude Code源码剖析 - Claude Code 上下文压缩机制
人工智能·python·ai
Cloud_Shy6183 小时前
解读《Effective Python 3rd Edition》:从练气到老魔(第五章 Item 33 - 35)
开发语言·人工智能·笔记·python·学习方法
abcy0712134 小时前
python pandas csv异步后台清洗前端优先返回成功信息
前端·python·pandas
颜酱4 小时前
LangChain使用RAG 入门:让大模型读懂你的私有文档
python·langchain
天天进步20154 小时前
Python全栈项目--校园智能宿舍管理系统
开发语言·python
测试员周周5 小时前
【AI测试智能体-面试】AI测试面试60题(附回答思路)
人工智能·python·功能测试·测试工具·单元测试·自动化·测试用例