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

打印内容:

相关推荐
zhongtianhulian10 分钟前
陶瓷行业导航网站:景德镇信息大全 — 采购指南与政策解读
人工智能·python
电子_咸鱼23 分钟前
常见面试题——滑动窗口算法
c++·后端·python·算法·leetcode·哈希算法·推荐算法
深圳佛手31 分钟前
jupyter notebook如何使用虚拟环境?
人工智能·python
Mqh18076242 分钟前
day38 gpu训练和call方法
python
ada7_1 小时前
LeetCode(python)230.二叉搜索树中第k小的元素
python·算法·leetcode·链表
江上鹤.1482 小时前
Day36官方文档的阅读
python
嗝o゚2 小时前
Flutter 无障碍功能开发最佳实践
python·flutter·华为
芝麻开门-新起点2 小时前
第13-1章 Python地理空间开发
开发语言·python
秋刀鱼 ..2 小时前
2026年电力电子与电能变换国际学术会议 (ICPEPC 2026)
大数据·python·计算机网络·数学建模·制造
znhy_233 小时前
day35打卡
python