【问题标题】:requests: 'module' object has no attribute 'get'请求:“模块”对象没有属性“获取”
【发布时间】:2016-07-15 18:15:00
【问题描述】:

我上周安装了requests 软件包,它运行良好。直到今天早上。我对此进行了编码,并收到了AttributeError: 'module' object has no attribute 'get' 消息:

import requests

r = requests.get('http://www.yellowpages.com/search?search_terms=coffee&geo_location_terms=Montreal%2C+QC')

我在其他帖子中读到这可能是因为我安装了多个 requests 软件包。 当我编码print(dir(requests)) 时,我得到两个列表..:

['__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__',
'requests']

['__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__',
'requests']

任何帮助将不胜感激。

西尔万

【问题讨论】:

  • requests.__file__ 给你什么?
  • 你调用了你的脚本 requests.py

标签: python python-3.x python-requests


【解决方案1】:

您是否可能将脚本命名为 requests.py,或者您在同一目录中有类似名称的文件?

【讨论】:

  • 就是这样,亚历克!我创建了一个 requests.py 文件。我删除了它,现在它可以工作了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-26
相关资源
最近更新 更多