Chinaunix首页 | 论坛 | 博客
  • 博客访问: 428108
  • 博文数量: 132
  • 博客积分: 2511
  • 博客等级: 大尉
  • 技术积分: 1385
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-11 15:10
文章分类

全部博文(132)

文章存档

2012年(18)

2011年(35)

2010年(60)

2009年(19)

分类: LINUX

2011-04-29 16:52:09

下午想写个解析网页的程序,从某网站抓点自己想要的东西,查了一下,python的urllib可以给干这种事情。
于是开搞。

写了个程序,起名urllib.py,在里面又import urllib
然后运行的时候,就报
Traceback (most recent call last):
  File "./urllib.py", line 3, in
    import urllib
  File "/home/mt/code/python/urllib.py", line 6, in
    u = urllib.urlopen("")
AttributeError: 'module' object has no attribute 'urlopen'

查了一下,在
找到了答案,04年的帖子了。。
This is a name clash. As your script has the same name as the library module, it imports itself instead of urllib in the library. To fix it, just rename to, say, /home/shalen/programming/python/tutorials/py/examineurllib.py
阅读(2150) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~