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

打印内容:

相关推荐
cup1120 分钟前
[开源] Meta Assistant / 告别命令行,我为一堆 Python 脚本做了一个 Windows 任务栏的“家”
windows·python·工具·nuitka·脚本运行
小小编程路1 小时前
Python 还有容器类型互转、进制转换、字符编码转换
开发语言·windows·python
Samooyou2 小时前
RAG项目案例--02在线检索&过滤流水线
人工智能·python·ai·全文检索·检索
动能小子ohhh2 小时前
DocForge平台的设计与开发--文件上传接口的实现
开发语言·人工智能·python·langchain·ocr·fastapi
ab_dg_dp2 小时前
Android 17+ 提取 AIDL 生成 Java 文件的实用脚本
android·java·python
夏语灬2 小时前
cryptography:Python 密码学标准库的终极选择
开发语言·python·密码学
CTA终结者3 小时前
期货开仓前保证金够吗:get_account 可用与占用字段对照
python·区块链
开源量化GO3 小时前
夜盘白盘衔接几分钟误下单:天勤交易时段与行情过滤
python·区块链
辣椒思密达3 小时前
Python公开数据采集实战:如何解决请求高频拦截与Session会话中断问题
开发语言·python
Albart5754 小时前
Python 实战教程:用 30 分钟学会解决真实问题
开发语言·python