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))
相关推荐
爱笑的眼睛1144 分钟前
超越MSE与交叉熵:深度解析损失函数的动态本质与高阶设计
java·人工智能·python·ai
Rose sait2 小时前
【环境配置】Linux配置虚拟环境pytorch
linux·人工智能·python
过期动态2 小时前
JDBC高级篇:优化、封装与事务全流程指南
android·java·开发语言·数据库·python·mysql
一世琉璃白_Y3 小时前
pg配置国内数据源安装
linux·python·postgresql·centos
liwulin05063 小时前
【PYTHON】COCO数据集中的物品ID
开发语言·python
小鸡吃米…3 小时前
Python - XML 处理
xml·开发语言·python·开源
我赵帅的飞起3 小时前
python国密SM4加解密
python·sm4加解密·国密sm4加解密
yaoh.wang3 小时前
力扣(LeetCode) 1: 两数之和 - 解法思路
python·程序人生·算法·leetcode·面试·跳槽·哈希算法
liwulin05064 小时前
【PYTHON-YOLOV8N】关于YOLO的推理训练图片的尺寸
开发语言·python·yolo
我送炭你添花4 小时前
Pelco KBD300A 模拟器:04+1.Python 打包详解:历史、发展与多种方式对比
python·测试工具·运维开发