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

打印内容:

相关推荐
江华森7 小时前
Python神经网络编程(四):Python从零搭建神经网络
开发语言·python·神经网络
nothing&nowhere16 小时前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
花酒锄作田17 小时前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang17 小时前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式
飞猪~21 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_9563198821 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_1 天前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质1 天前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗1 天前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python