我发现文件直接用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. hive Hsql

    show databases; use flume; show tables; desc flume; alter table table_name add columns(dt string); a ...

  2. mysql的一些基本常识

    1.主键的选取 主键的字段不能有null存在 主键应该使用bigint自增,而不是int 主键的选取默认为id 联合主键:就是多个字段被设置为主键,这里主键字段的值是允许相同的,只要不是所有字段相同即 ...

  3. K8S存储相关yaml

    一.ConfigMap 1.使用目录创建 vim game.properties vim ui.properties 在一个文件夹下创建两个文件,通过以下命令创建 kubectl create con ...

  4. Git--02 Devops介绍及git安装部署

    目录 1. Devops介绍 01. 运维介绍 02. Devops是什么 03. Devops能干嘛 04. Devops如何实现 2. Git版本控制系统 01. 版本控制系统简介 02. 为什么 ...

  5. 关于.net中使用reportview所需注意

    参考文章链接:http://www.cnblogs.com/watercold/p/5258608.html 这段时间在做一个winform的小项目时,发现使用.net中的ReportViewer插件 ...

  6. 查看linux服务器的版本信息

    查看linux系统信息 uname -a Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UT ...

  7. 【LeetCode】队列 queue(共8题)

    [346]Moving Average from Data Stream [353]Design Snake Game [363]Max Sum of Rectangle No Larger Than ...

  8. angular 组件通信

    单页面应用组件通信有以下几种,这篇文章主要讲 Angular 通信 父组件 => 子组件 子组件 => 父组件 组件A = > 组件B 父组件 => 子组件 子组件 => ...

  9. python基础:5.请编写一个函数实现将IP地址转换成一个整数。

    如 10.3.9.12 转换规则为:        10            00001010
         3            00000011
         9          ...

  10. 09.事务管理、整合jpa、整合mybatis

    事务管理 spring-boot-starter-jdbc会自动默认注入DataSourceTransactionManager spring-boot-starter-data-jpa会自动默认注入 ...