AttributeError: 'module' object has no attribute 'post'问题
来源:互联网 发布:可可网络验证通杀 编辑:程序博客网 时间:2024/05/30 05:41
在学习python网页爬虫时,测试requests的post方法进行表单提交时,命名.py文件为requests.py 代码如下:
import requestsparams={'firstname':'xing','lastname':'ming'}r=requests.post("http://pythonscraping.com/files/processing.php",data=params)print r.text
在运行时,报错:AttributeError: ‘module’ object has no attribute ‘post’
查找资料发现,命名.py脚本时,不能与模块名,预留字同名,若同名,生成的.pyc文件就有问题,导致报错。
解决办法:
首先修改.py脚本的命名,不能与模块名,预留字同名。
修改完成后,还需要删除工程中生成的.pyc文件,因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件。
然后运行,即可成功。
0 0
- AttributeError: 'module' object has no attribute 'post'问题
- AttributeError: ‘module’ object has no attribute’ 问题
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- 问题AttributeError: ‘module’ object has no attribute ‘sub’
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute 'LabelMap'
- AttributeError: 'module' object has no attribute 'XXX'
- AttributeError: 'module' object has no attribute 'urlopen'
- AttributeError:'module' object has no attribute 'classify'
- AttributeError: ‘module’ object has no attribute’xxx’
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute 'AF_INET'
- 如何搞定SVN目录的cleanup问题和lock问题
- 处女项目后关于IC验证经验的总结
- 树莓派安装mrpt
- Android 异步任务
- Java文档 [转载oracle]
- AttributeError: 'module' object has no attribute 'post'问题
- Echarts仪表盘
- self.XX点语法/队列和栈的区别/堆区与栈区的区别
- Unity3D for VR 学习(1): 又一个新玩具 暴风魔镜 4(Android)
- PHP执行效率问题总结
- Activity数据返回 startActivityForResult()用法详解
- 初探服务器:使用服务器运行自己的程序
- Android view 坐标
- 找零钱的方案数以及所需最少张数的钞票的方案