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

打印内容:

相关推荐
HjhIron13 小时前
Python列表与LLM接口实战:从切片到DeepSeek调用
python
搬砖的小码农_Sky13 小时前
macOS Sequoia上如何安装Python开发环境?
开发语言·python·macos
Rauser Mack13 小时前
编程纯小白,五分钟用AI做了个小游戏(附Prompt)
人工智能·python·html·prompt·ai编程
py小王子13 小时前
期刊复现| Python 实现带边缘密度与残差检验的回归拟合图
python·期刊复现
deepin_sir13 小时前
14 - 面向对象编程
开发语言·python
知识分享小能手13 小时前
Flask入门学习教程,从入门到精通,Flask智能租房——列表页 知识点详解(7)
python·学习·flask
极客小云13 小时前
【从 while 循环到可视化智能体:深入拆解 Agent Loop、Codex 风格工具调用、OpenClaw 与 Hermes 背后的技术细节】
数据库·python·大模型·agent·codex·openclaw·hermes
Larcher14 小时前
Python List、切片与大模型:从入门到实践的优雅之旅
python·ai编程
用户63371973590114 小时前
_winapi.CreateProcess....FileNotFoundError: [WinError 2] 系统找不到指定的文件
python
清水白石00814 小时前
Python 数据建模指南:dataclass、TypedDict 与 Pydantic 的选型博弈
前端·javascript·python