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))
相关推荐
j7~几秒前
【Python】(篇七)《使用Python库》 -- 详解
开发语言·后端·python·编程学习·python标准库·python第三方库·python拓展
databook31 分钟前
手把手带你走一遍:机器学习模型如何用FastAPI和Docker部署
python·docker·fastapi
DanCheng-studio1 小时前
计算机技术与科学毕业设计简单的方向建议
python·毕业设计·毕设
言乐61 小时前
Python排名统计折线图
开发语言·python·django·virtualenv·pygame
浩瀚地学1 小时前
deepagents学习打卡day08
经验分享·笔记·python·学习·agent
卷无止境1 小时前
便宜模型和贵模型到底差在哪儿?一份关于Claude与GPT分级体系的深度梳理
后端·python
玩美移动1 小时前
AI Skin Analysis API 技术解析:文件上传、异步任务与结果读取
java·人工智能·python
j7~2 小时前
【Python】(篇六)《基础语法(函数、列表和元组、字典、文件)》---详解
开发语言·python·文件·函数·字典·编程学习·元组与列表
Wx-bishekaifayuan2 小时前
springboot户外登山社交小程序19787-计算机课程设计、毕业设计
spring boot·后端·python·spring·elasticsearch·django·课程设计
FYKJ_20102 小时前
springboot刑事案件管理系统03047-计算机课程设计、毕业设计
vue.js·spring boot·python·mysql·typescript·spark·django