正则中的前瞻和后顾 import re key=r'<h1>Hello world</h1>' p1=r'(?<=<h1>).+(?=</h1>)' pattern=re.compile(p1) print(pattern.findall(key)) 输出:['Hello world']