import urllib.request
import re
page = urllib.request.urlopen("http://www.samair.ru/proxy/ip-address-01.htm").read()
re.findall('\d+\.\d+\.\d+\.\d+', page)
我不明白为什么上面写着:
文件“C:\Python33\lib\复制“,第201行,芬德尔 return\u compile(模式,标志).findall(字符串) TypeError:不能对类似于字节的对象使用字符串模式
工作并给了我结果:
^{pr2}$编辑
读取
urllib.request.urlopen
返回的类文件对象的结果是一个bytes对象。您可以将其解码为unicode字符串并使用unicode正则表达式:。。。或使用字节正则表达式:
^{pr2}$取决于您希望使用的数据类型。在
相关问题 更多 >
编程相关推荐