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

打印内容:

相关推荐
chimchim6613 小时前
Azure Data Factory (ADF)‌ 之databricks使用
后端·python·flask
ふり13 小时前
测试的“三重境界”:黑盒、白盒、灰盒的对比与实践
网络·python·测试工具·需求分析
开源量化GO13 小时前
多合约期货策略目标持仓怎么更新不容易乱
python·区块链
Sylvia33.14 小时前
2026世界杯全套数据API接入教程:WebSocket实时进球推送实例
java·网络·python·websocket·网络协议
zyl8372114 小时前
Python 线性代数:矩阵与向量
开发语言·python·机器学习
金銀銅鐵14 小时前
用 Tkinter 实现一个简单的干支纪年计算器
后端·python
AC赳赳老秦14 小时前
OpenClaw+MySQL 深度应用:自动生成建表语句、索引优化建议与数据迁移脚本
开发语言·数据库·人工智能·python·mysql·算法·openclaw
西贝爱学习14 小时前
旅游推荐数据集.csv
python·数据集·旅游
qcx2314 小时前
【AI Daily 2026-06-05】「持续迭代」已成为 2026 年 Agent 研究的核心命题
人工智能·python·agent
2601_9611940214 小时前
2026四级词汇闪过电子版|高频词+真题词速记PDF
数据库·python·django·pdf·pygame