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

打印内容:

相关推荐
eric-sjq7 小时前
仅0.6B参数如何锁住超长记忆?Xiaothink-T17-RWKV5-MLA 架构深度解析:RWKV-v5 × MLA 的“降维打击“
python·架构
张小凡vip7 小时前
Python爬虫实战:高效稳定的文件下载模块设计与实现
开发语言·爬虫·python
小趴蔡ha16 小时前
02 Anaconda、Python 与机器学习开发环境入门
python·机器学习·anaconda
2401_8685347816 小时前
RTOS之RT-Thread & Linux:线程/进程管理与调度核心差异分析
c++·python
数字化转型分享点滴17 小时前
富士康、蓝思科技为何选择四化信息?MES制造执行系统的实践
python·科技
wling030117 小时前
vasp虚频计算-python脚本
开发语言·windows·python·vasp计算
魔镜前的帅比17 小时前
(开源项目)x-claw(总)
python·ai·rust·开源
xrandzj18 小时前
Python面向对象编程入门:类、实例、初始化与封装实践
开发语言·python
matlabgoodboy20 小时前
计算机毕设代做|Java Python Matlab APP 全套开发设计
java·python·课程设计
用户83562907805121 小时前
Python Word 转 PDF 和 PDF 转 Word 指南
后端·python