Classwork 5 - Check the HTML Tags

python 复制代码
#获取html的tag

html = ['<body>Welcome to our course! It would be an awesome experience</body>',
 '<article>To be a data scientist, you need to have knowledge in statistics and mathematics</article>',
 '<nav>About me Links Contact me!']
import  re


for s in html:
    match_tag= re.match(r"<(\w+)>.*?</\1>",s)
    if match_tag:
        tag_name = match_tag.group(1)
        print(f"you can find tag:{tag_name}")  ## 加 f 前缀,{tag_name} 会替换为实际标签名


for s in html:
    match_tag = re.match(r"<(\w+)>.*?</\1>", s)
    if match_tag:
        tag_name = match_tag.group(1)
        print("you can find tag:{tag_name}".format(tag_name=tag_name))
相关推荐
Alan_69120 分钟前
聊聊 Swagger/Postman/Apifox 的真实选型与 Python 项目实战
python·测试工具·postman
智慧物业老杨1 小时前
物业绿化数智化权责管控方案:基于工单平台的双层权限追溯模块落地实践
python
Metaphor6922 小时前
使用 Python 在 Word 文档中添加批注
python·word
FreakStudio2 小时前
WIZnet 开源方案分享:W55MH32 开发板 + 小智 AI实现以太网版本的小智机器人
python·单片机·嵌入式·大学生·面向对象·并行计算·电子diy·电子计算机
会周易的程序员2 小时前
使用 pybind11 封装 C++ 日志库 microLog 为 Python 模块
java·c++·python·物联网·架构·日志·aiot
一只专注api接口开发的技术猿3 小时前
电商评论自动化监控与情感数据分析完整落地教程(附可直接运行 Python 代码)
大数据·数据库·python·数据分析·自动化
HAPPY酷3 小时前
【ROS2】 Conda 环境搭建(命令行版)
linux·运维·python·ubuntu·机器人·conda
柒和远方4 小时前
LeetCode 4. 寻找两个正序数组的中位数 —— 二分划分的艺术
javascript·python·算法
学也学不废5 小时前
Flask问答系统与LAUR模型
人工智能·python·机器学习·分类·数据挖掘
lewis_lk5 小时前
uv: Python 新一代极速包管理工具
python