cosmos队长 2014-09-24 07:41 采纳率: 0%
浏览 2012
已采纳

用eclipse 写python时报错

鄙人python初学者,想跟着网上视频做一个爬虫,用的是python2.78,工具是eclipse,具体代码如下
#coding:utf-8
import urllib
str0='让大家扫兴了'
title=str0.find(r'<a title')
print title
href=str0.find(r'href=')
print href
html=str0.find(r'.html')
print html
url=str0[href+6:html+5]
print url
content=urllib.openlib(url).read()

前面直到打印url都很正常,但是就是到使用openlib时出现了如下错误

Traceback (most recent call last):
File "E:\���\eclipse\dropins\project\����\des\des.py", line 13, in
content=urllib.openlib(url).read()
AttributeError: 'module' object has no attribute 'openlib'

大家否告诉我错误的原因以及解决方法,多谢了

  • 写回答

1条回答 默认 最新

  • fortianwei 2014-11-05 08:38
    关注

    不是urllib.openlib(url).read()而是urllib.urlopen(url).read()吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器