【发布时间】:2011-07-08 06:07:51
【问题描述】:
所以,我有这个代码:
url = 'http://google.com'
linkregex = re.compile('<a\s*href=[\'|"](.*?)[\'"].*?>')
m = urllib.request.urlopen(url)
msg = m.read()
links = linkregex.findall(msg)
然后python返回这个错误:
links = linkregex.findall(msg)
TypeError: can't use a string pattern on a bytes-like object
我做错了什么?
【问题讨论】:
-
你运行的是哪个版本的 Python?
标签: python regex python-3.x typeerror