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

打印内容:

相关推荐
一勺菠萝丶4 小时前
macOS 安装 Python 包报错:`externally-managed-environment` 怎么解决?
python
醒李4 小时前
盲人出行辅助系统原型
人工智能·python·目标检测
PILIPALAPENG5 小时前
第4周 Day 3:多 Agent 协作——让 Agent 们"组队干活"
前端·人工智能·python
Omics Pro5 小时前
填补蛋白质组深度学习预处理教学空白
人工智能·python·深度学习·plotly·numpy·pandas·scikit-learn
万邦科技Lafite6 小时前
实战演练:利用京东API一键抓取商品详情
数据库·redis·python·缓存·开放api·淘宝开放平台
TheRouter6 小时前
OpenClaw 上下文瘦身:3 个实验
开发语言·python·ai
日光明媚6 小时前
TensorRT-LLM 中对 wan 加速流程与方法
人工智能·python·计算机视觉·stable diffusion·aigc
Promising_GEO6 小时前
全球综合评估模型-GCAM模型的安装与参数解读
开发语言·python·遥感·空间分析
TechWayfarer8 小时前
IP归属地API实战指南:用IP数据云解析日志挖掘用户地域分布
大数据·开发语言·网络·python·tcp/ip
Cloud_Shy6188 小时前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十一章 Python 包跟踪器 中篇)
数据库·python·sql·数据分析·excel·web