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

  

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

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

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

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

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

  

  

AttributeError: module 'requests' has no attribute 'get'的错误疑惑的更多相关文章

  1. 解决:AttributeError: module 'requests' has no attribute 'post'”

    今天学习Requests库,当用pip install requests安装后,写了一段代码报错:AttributeError: module ‘requests‘ has no attribute ...

  2. 解决:AttributeError: module 'requests' has no attribute 'get'”

    今天学习Requests库,当用pip install requests安装后,写了一段代码报错:AttributeError: module 'requests' has no attribute ...

  3. AttributeError: module 'requests' has no attribute 'get' 遇到了这个错误,是因为我把python关键字做了包名。。。

    初学者总会犯各种低级错误,这是其一,特此记录.

  4. (转)Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding

    基于python3.6.1版本,在一个.py文件中,加入这3行:import requests, re, sysreload(sys)sys.setdefaultencoding("utf- ...

  5. AttributeError: 'module' object has no attribute get'

    最近在写python requests相关内容易,突然报错AttributeError: 'module' object has no attribute 'get'" 脚本肯定没问题 怎么 ...

  6. Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding'

    基于python3.6.1版本,在一个.py文件中,加入这3行: import requests, re, sys reload(sys) sys.setdefaultencoding("u ...

  7. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  8. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  9. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

随机推荐

  1. mt-picker 样式修改

    // html : <div class="applyInformations" @click="chooseSex"> <p>性别&l ...

  2. owaspbwa tickets

    owaspbwa tickets 来源  https://sourceforge.net/p/owaspbwa/tickets/ 192 SQL Injection in pic_id paramet ...

  3. linux系统部署war包,查看tomcat日志

    1.部署war包app/tomcat/bin在tomcat/bin 目录下启动 .startup.sh,在启动过程中tomcat会对war包进行解压,形成相应的项目目录 执行命令:./startup. ...

  4. 负载均衡算法WeightedRoundRobin(加权轮询)简介及算法实现

    Nginx的负载均衡默认算法是加权轮询算法,本文简单介绍算法的逻辑,并给出算法的Java实现版本. 本文参考了Nginx的负载均衡 - 加权轮询 (Weighted Round Robin).     ...

  5. Redis在windows下的环境搭建

    Redis在windows下的环境搭建 下载windows版本redis,,官方下载地址:http://redis.io/download, 不过官方没有Windows版本,官网只提供linux版本的 ...

  6. 接口需要上一个接口的返回值(unittest)

    import unittest,requests ''' 使用unittest框架的时候,这个接口需要上一个接口的返回值 ''' class Test_case(unittest.TestCase): ...

  7. 【leetcode】572. Subtree of Another Tree

    题目如下: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure ...

  8. linux学习-linux基础和帮助

    1.终端terminal (1)设备终端 键盘,鼠标,显示器 (2)物理终端(/dev/console) 控制台concole (3)串行终端(/dev/ttyS#) ttyS (4)虚拟终端(tty ...

  9. Angular JS - 2 - angularjs helloworld

    材料下载  https://github.com/liuch0228/AngularJS-learn.git 1.使用原生jquery实现 实现输入框内容 在页面上跟随输入值动态更新 项目路径 < ...

  10. Shiro安全框架的说明及配置入门

    Shiro是什么? Shiro是一个非常强大的,易于使用的,开源的,权限框架.它包括了权限校验,权限授予,会话管理,安全加密等组件 什么时候使用它呢? 如果你是设计RBAC基础系统,需要编写大量用于权 ...