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

打印内容:

相关推荐
规划GIS会14 分钟前
ima知识库第二弹,Python for ArcGIS Pro | 简简单单写个脚本工具
开发语言·python·arcgis
fengchengwu201223 分钟前
python下载m3u8格式视频
开发语言·python·m3u8
暴力袋鼠哥25 分钟前
基于Flask的跨境电商头程预警分析系统
后端·python·flask
在下_诸葛39 分钟前
DeepSeek的API调用 | 结合DeepSeek API文档 | Python环境 | 对话补全(二)
人工智能·python·gpt·prompt·aigc
漫谈网络1 小时前
闭包与作用域的理解
python·装饰器·闭包·legb
滴答滴答嗒嗒滴1 小时前
Python小练习系列 Vol.5:数独求解(经典回溯 + 剪枝)
python·深度优先·剪枝
Alger_Hamlet1 小时前
Pycharm 2024.3 Python开发工具
ide·python·pycharm
techdashen1 小时前
性能比拼: Go(Gin) vs Python(Flask)
python·golang·gin
techdashen1 小时前
性能比拼: Go标准库 vs Python FastAPI
python·golang·fastapi
键盘上的GG小怪兽GG2 小时前
Centos主机检查脚本
开发语言·网络·python