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

打印内容:

相关推荐
卷无止境7 小时前
用 SimPy 做离散事件仿真:时钟不走步,事件自己排队
后端·python
撸码猿8 小时前
数据采集场景的语序点选验证码:90.2% 整词准确率的本地 OCR 实践
python·ocr
用户0332126663678 小时前
使用 Python 在 Excel 中创建折线图和条形图
python·excel
木子欢儿9 小时前
Ubuntu 26.04 LTS 安装Python 3.12
linux·运维·服务器·python·ubuntu
Wellijohn9 小时前
Python 异步并发:我把 5 个坑踩完了,你照着抄模板就行
python
AI创界者10 小时前
Python 进阶实战(六十二章):分布式定时任务、异步工作流与幂等补偿机制实战
人工智能·python·aigc
炸薯条!11 小时前
Python面向对象基础:类与对象、实例方法、魔法方法和属性详解
java·开发语言·python
tryCbest12 小时前
Python 爬虫从入门到实战(二):进阶篇——反爬对抗、并发与动态页面
开发语言·爬虫·python
VIP_CQCRE12 小时前
GPT Image 2.6 动态表情交付别只发预览:GIF 文件校验、哈希清单与下载排错
图像处理·人工智能·python·gif
2601_9679873712 小时前
使用 NumPy 和 Python 实现梯度下降
python·机器学习·线性回归·numpy·梯度下降