大神们,帮看下在python3.6上运行出现这个错误帮解决下,谢谢了
import urllib.request
import re
req=urllib.request.urlopen("http://www.imooc.com/course/list")
buf = req.read()
listurl = re.findall(r'http:.+?\.jpg',buf)
i=0
for url in listurl:
f=open(str(i)+'.jpg','w')
req=urllib.request.urlopen(url)
buf= req.read()
f.write(buf)
i=i+1
f.close()
错误:Traceback (most recent call last):
File "C:\Users\zhuzhihao\Desktop\bb.py", line 6, in <module>
listurl = re.findall(r'http:.+?\.jpg',buf)
File "E:\python\lib\re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object
>>>