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

打印内容:

相关推荐
benchmark_cc11 小时前
一次获取多只股票实时行情:QuantDash `quotes.get(symbols=[...])` 批量快照
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
geovindu12 小时前
python: PCA
开发语言·后端·python·算法
AI模型调用笔记12 小时前
流式 API 的 usage 为 null?用 cURL 看尾帧,别漏空 choices
python
天诰13 小时前
SA-T-06 轨迹数据工程 脏数据检测
人工智能·python·算法·语言模型·ai编程
Java后端的Ai之路15 小时前
Anthropic 官方文章《Building always-on agents》构建指南
开发语言·网络·python
badhope15 小时前
Agent 说发布成功,文章却 404:我补了 4 张回读收据
后端·python·ai编程
xurileidian15 小时前
第 30 篇 · 边玩边学Python · 猜数字小游戏 把判断循环异常串起来
前端·python·算法
leeshuqing16 小时前
剪刀石头布-Python练习
python·游戏·优化·列表·字典·控制语句
ZhuoAIStage16 小时前
图上有设备,机房条件0命中:剧院舞台音视频提资缺项,AI智能体为何判「需补充」不判「设计错漏」
python·正则表达式·舞台工艺·智能体审图·提资核查
汤姆宝库16 小时前
HNSW:分层图上的贪心检索
开发语言·python