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

打印内容:

相关推荐
databook3 小时前
使用 SciPy 库进行时间序列分析
python·数据分析·scipy
java资料站3 小时前
十一、评估测试
开发语言·人工智能·python
szial3 小时前
网络爬虫与 CDP 实战(二):浏览器能访问,Python 却被拒绝?拆开登录态与 CSRF
爬虫·python·csrf
hengdonghui4 小时前
Writeup 4 CSS CTF Semester 2 2026 - Lamp Drill
ctf·re
青少儿编程课堂4 小时前
后缀自动机解析:本质不同子串与最长重复片段统计
c++·python·算法·bfs·信息学竞赛
怕浪猫5 小时前
LLM 面试必问的 8 个问题,答不上来直接淘汰
人工智能·python·面试
老歌老听老掉牙6 小时前
从三维旋转的深度解析到Python实现:绕任意轴旋转的奥秘
python·三维旋转
打工仔折腾 AI6 小时前
工业场景下时序库与实时计算一体化架构选型实践对比
java·开发语言·后端·python·性能优化·架构·ai agent 实战
梦幻精灵_cq6 小时前
sumdir——一个伪python.built-in的“术法”打造
python
weixin_440730508 小时前
函数return、参数、参数组、递归函数、高阶函数等小结
开发语言·python