def getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0
r'src相当于调用正则表示是的格式,"(.+?\.jpg)" pic_ext'是要判断的内容的格式
不是要判断内容的格式