正则找元素
# 导入正则表达式 import re # 参数2 str1 = "<html>a='as1d32as1d654as54d65asd465asd4'</html>" # 参数1 pattern = r"<html>a=(.*?)</html>" # 调用re中的寻找方法search result = re.search(pattern, str1) if result: extracted_text = result.group(1) print(extracted_text) else: print("未找到匹配的内容")
'''
'as1d32as1d654as54d65asd465asd4'
'''