zoukankan      html  css  js  c++  java
  • AttributeError: module 'requests' has no attribute 'get'的错误疑惑

    我发现文件直接用requests.get(url)会提示我AttributeError: module 'requests' has no attribute 'get'

      

    我把问题百度了一下,解决方法是: 

      python源文件与关键字重名了。

      1. 命名py脚本时,不要与python预留字,模块名等相同

      2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件),重新运行代码;或者找一个可以运行代码的环境,拷贝替换当前机器的.pyc文件即可

    后来我发现我的该路径下有一个requests.py文件的程序,我把它删除掉,就不会报这种错了。

      

      

  • 相关阅读:
    String
    Map和Set
    js的栈与堆
    js的私有属性
    随便谈一谈原型
    前端页面优化提速
    nth-child和nth-of-type
    重复输出字符串
    闭包
    mongodb内嵌文档的查询
  • 原文地址:https://www.cnblogs.com/hum0ro/p/9536010.html
Copyright © 2011-2022 走看看