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