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

打印内容:

相关推荐
fillwang13 小时前
间接料库存预警报告设计
python·rpa
.柒宇.13 小时前
AI 掘金头条项目-新闻模块实现
数据库·后端·python·fastapi
Chockong13 小时前
06_yolox_s.onnx的推理验证
python·神经网络
七颗糖很甜13 小时前
台风数据免费获取教程
大数据·python·算法
DeniuHe13 小时前
sklearn.utils.validation.check_random_state 详解
人工智能·python·sklearn
tangweiguo0305198713 小时前
阿里云百炼微调完整实战:从数据到部署
人工智能·python·langchain
念恒1230613 小时前
Python(简单判断) —— 从 if 开始
python·学习
BU摆烂会噶13 小时前
【LangGraph】线程级持久化深度实战(PostgreSQL + 重放机制)
数据库·人工智能·python·postgresql·langchain