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

打印内容:

相关推荐
北冥有鱼被烹21 小时前
Linux timeout 命令完全指南:指定固定时间并发送固定信号
python
SunnyDays10111 天前
如何使用 Python 将 PowerPoint(PPT 或 PPTX)转换为 Markdown
python·ppt转markdown·pptx转markdown·powerpoint转md
PiaoKe___1 天前
云手机原理与 Python 自动化实战:ADB、REST API、WebSocket 群控入门
python·智能手机·自动化
co_wait1 天前
Python 迭代器(一)
python
Yolanda_20221 天前
15.dataloader的使用
python
杨杨杨大侠1 天前
Jev、Kev、Laya:决策模型怎么选,什么时候需要微调?
人工智能·python·agent
LOVE️YOU1 天前
Python 在定义函数时,究竟定义的是什么?
python
段一凡-华北理工大学1 天前
大模型应用开发 100 天:Python + LLM 从入门到精通 day26~Prompt 调试与优化——A/B 测试与效果评估
windows·python·大模型·prompt·智能体·提示词工程·高炉智能化
Minecraft红客1 天前
以撒的结合
python·游戏·电脑·娱乐
Circ.1 天前
Python 调试 Litellm 本地大模型接口:模型列表与对话接口实操踩坑记录
开发语言·python