我发现文件直接用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. Qt 如何配置维护更新工具 MaintenanceTool ?

    http://download.qt.io/static/mirrorlist/ 添加对应版本的地址,拉取最新元信息. http://mirrors.ustc.edu.cn/qtproject/onl ...

  2. 2018-8-10-C#-TextBlock-上标

    title author date CreateTime categories C# TextBlock 上标 lindexi 2018-08-10 19:16:52 +0800 2018-2-13 ...

  3. pwd - 显示出当前/活动目录的名称

    总览 (SYNOPSIS) pwd [OPTION] 描述 (DESCRIPTION) 显示出 完整的 当前 活动目录 名称. --help 显示 帮助 信息, 然后 退出 --version 显示 ...

  4. html5 像素模拟渐变

    代码实例: <!DOCTYPE html> <html> <head> <style> canvas{ background:#eee; } </ ...

  5. extjs6.0 treepanel设置展开和设置选中

    var treePanel = { id: "treeUrl", xtype: "treepanel", useArrows: true, // 节点展开+,- ...

  6. python 利用subprocess调用cmd命令程序,并正确输出控制台的输出中文

    平台Python3.7 1.利用控制台运行程序后在控制台会输出中文提示,但是用python调用subprocess.run函数后返回的输出是乱码,于是,解决方法是用subprocess.check_o ...

  7. delphi 打开和关闭外部exe

    一.打开外部exe 1.use文件-SHELLAPI 2.ShellExecute(handle,'open','E:\test.exe','-s','',SW_SHOWNORMAL); 二.关闭外部 ...

  8. 2.xml约束技术----------dtd约束

    1.xml的约束 (1)为什么需要定义约束了 比如现在定义一个person的xml文件,只想要这个文件里面保存人的信息,比如name age等,但是如果在xml文件中写了一个元素<猫>,发 ...

  9. 回炉Spring--事务及Spring源码

    声明式事务 配置文件信息: /** * @EnableTransactionManagement 开启基于注解的事务管理功能 * 1.配置数据源 * 2.配置事务管理器来管理事务 * 3.给方法上标注 ...

  10. SCJP读书之知识点:

    1:实例变量和局部变量 实例变量:是在类中进行声明的,可以有public,private等修饰符进行修饰. 局部变量:在方法中进行声明,生命周期就是方法开始,到方法结束.但是可以进行对象的引用来调用. ...