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

打印内容:

相关推荐
henrylin99997 小时前
Quant Agent 完整系统规格
python·量化
三川6987 小时前
Tkinter库的学习记录10-Message与Messagebox
python
吃饱了得干活7 小时前
别只会传 temperature!一文挖透 LangChain 模型配置:Profile、全参数与运行时动态覆盖
python·langchain
shuoyuanAI7 小时前
张家口专业的aigeo优化品牌找哪家
大数据·人工智能·python
卷无止境7 小时前
《Deep Analysis with Polars》进阶分析技巧——深入解读
后端·python
大博士.J7 小时前
视频号主体违规与认证上限?正确的解决方式
运维·python·自动化
Mr.朱鹏7 小时前
【FastAPI 全栈实战 | 第2篇】Pydantic 数据校验与响应模型 —— 让 Bug 死在请求进来的那一刻
人工智能·python·fastapi
Xiangchu_7 小时前
安徽硅胶厂的转型困局:从家电到汽车,卡在哪
经验分享·python·阿里云·eclipse·汽车·制造
CTA终结者8 小时前
近期AI量化工具推荐,围绕最难推进的环节选择
人工智能·python