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

打印内容:

相关推荐
小徐学编程-zZ1 小时前
量产测试数据
python·压力测试·数据库架构
QQ8057806511 小时前
django基于机器学习的电商评论情感分析系统设计实现
python·机器学习·django
wx09091 小时前
stata实现机器学习的环境配置
python·机器学习·stata
nuowenyadelunwen3 小时前
CS 61A Lab 2 笔记:短路求值、高阶函数与 Lambda 表达式
python·函数式编程·cs61a·berkeley
qq_422828624 小时前
android图形学之SurfaceControl和Surface的关系 五
android·开发语言·python
weixin_444012934 小时前
c++如何将std--vector直接DUMP到二进制文件_指针地址直写【附代码】
jvm·数据库·python
woxihuan1234564 小时前
Go语言中--=运算符详解:位右移赋值操作的原理与应用
jvm·数据库·python
石山代码4 小时前
Python 数据分析三大库:NumPy + Pandas + Matplotlib
python·数据分析·numpy
如竟没有火炬4 小时前
用队列实现栈
开发语言·数据结构·python·算法·leetcode·深度优先
yivifu5 小时前
CustomTkinter的布局管理器介绍及应用
python·gui·customtkinter·pdf去水印