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

打印内容:

相关推荐
mengge.cloud13 小时前
Python基础保姆级!从入门到入土
开发语言·python·云原生·pygame
qq_1588954111117 小时前
Suno-API 是什么?官方 V6 模型与 Python / TypeScript 接入指南
python·ai音乐·suno api
学无止境小袁同学1 天前
Google ADK 学习指南
python·llm·agent·多agent·google adk·llmagent·agent cli
郝学胜-神的一滴1 天前
Effective Python 条款35:用类封装替代生成器异常注入
开发语言·人工智能·python·金融·pandas·scikit-learn·matplotlib
LK_071 天前
【力扣】142. 环形链表 II |Python
python·leetcode·链表
wuyk5551 天前
Python办公自动化-第02讲-Excel文件认知与四大库选型
开发语言·python·excel
用户54817845909501 天前
Java 与 Python 在大模型与智能体领域的选型
java·python
yiangL_1 天前
1、Python 输入输出实验|print 与 input 人机交互实践
开发语言·python·人机交互
高洁011 天前
世界模型的因果内核:从预测表象到理解机制
人工智能·python·深度学习·transformer·迁移学习