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))
相关推荐
冬至喵喵9 分钟前
构建 CLI 的 Python 框架:Typer技术介绍
开发语言·chrome·python
nimadan1214 分钟前
豆包写小说软件2025推荐,专业写作助力灵感迸发
大数据·人工智能·python
I love studying!!!30 分钟前
Web项目:从Django入手
后端·python·django
badhope1 小时前
Agent智能体全面深入教程:架构、机制与工程实践
人工智能·python·机器人
后藤十八里1 小时前
极验4滑动拼图验证码逆向笔记
笔记·爬虫·python
小江的记录本1 小时前
【Swagger】Swagger系统性知识体系全方位结构化总结
java·前端·后端·python·mysql·spring·docker
m0_738120721 小时前
网络安全编程——如何用Python实现SSH 服务端和SSH 反向 Shell(突破内网)
python·web安全·ssh
sinat_255487811 小时前
泛型·学习笔记
java·jvm·数据库·windows·python
猫咪老师1 小时前
Day9 Python 关于协程的最详细介绍!
python
单片机学习之路1 小时前
【Python】输入input函数
开发语言·python