python 错误AttributeError: 'module' object has no attribute 'AF_INET'
写了一个简单的python socket的程序。运行时,报错如下

原因:文件的命名与Python的function的命名冲突
修改名称后,发现还是无法运行,检查目录下面是否有

这样子的一个文件,删除即可。
据我的理解,应该是我们自己命名重写了Python的socket函数。
附上我的小代码
import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n') while True:
data = mysock.recv(512)
if ( len(data) < 1 ) :
break
print data; mysock.close()
python 错误AttributeError: 'module' object has no attribute 'AF_INET'的更多相关文章
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- python 脚本运行时报错: AttributeError: 'module' object has no attribute ***
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...
- Python AttributeError: 'Module' object has no attribute 'STARTF_USESHOWINDOW'
夫学须志也,才须学也,非学无以广才,非志无以成学.--诸葛亮 生活有度,自得慈铭 --杜锦阳 今天新来的同事安装环境遇到个莫名其妙的问题: AttributeError: 'Module' objec ...
- 【Python】【亲测好用】安装第三方包报错:AttributeError:'module' object has no attribute 'main'
安装/卸载第三包可能出现如下问题及相应解决办法: 在pycharm编辑中,使用anconda2更新.卸载第三方包时,出现如下错误: AttributeError:'module' object has ...
- python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
AttributeError: 'module' object has no attribute 'SSL_ST_INIT' 问题背景: 下载工具wydomain,安装依赖包以后,出现下图问题. 几经 ...
- python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'(转)
原文地址:http://www.cnblogs.com/zhaijiahui/p/7344778.html AttributeError: 'module' object has no attribu ...
- AttributeError: 'module' object has no attribute 'enableTrace'
Traceback (most recent call last): File "Long-lived-connection.py", line 29, in <module ...
- 在运行create_list.sh时候报错:AttributeError: 'module' object has no attribute 'LabelMap'
Traceback (most recent call last):File "/opt/xuben-project/caffe/data/VOC0712/../../scripts/cre ...
随机推荐
- JspWriter与PrintWriter的关系
一.JspWriter与PrintWriter的关系: 1.都是继承自java.io.Writer类. JspWriter可以在JSP页面中直接用out对象输出.可以用pageContext.getO ...
- 当使用System,out.println()打印一个对象是自动调用toString方法
在Java中,所有的对象都是继承自Object,自然继承了toString方法,在当使用System,out.println()里面为一个对象的引用时,自动调用toString方法讲对象打印出来.如果 ...
- Hibernate一级缓存和二级缓存深度比较
1.什么是缓存 缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据, ...
- android 5.1 API简介
android 5.1介绍: http://developer.android.com/about/versions/android-5.1.html?utm_campaign=lollipop-51 ...
- Mysql笔记5之查询
1查询所有的列 select *from student 2查询指定列 select name,age from student 3查询时候使用别名 select name as 别名,age as ...
- double类型之四舍五入
题目: A - Tutor Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64u Submi ...
- Servlet程序开发--实例操作:MVC设计模式应用
以前做过一个登录程序,是用JSP+JavaBean完成的,最大的问题,JSP文件内容太多了. 1. VO 2. DBC 3. DAO 3.1 impl 3.2 proxy 4. Factory 5. ...
- AIM Tech Round 3 (Div. 2) B 数学+贪心
http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...
- 增加 addDataScheme("file") 才能收到SD卡插拔事件的原因分析 -- 浅析android事件过滤策略
http://blog.csdn.net/silenceburn/article/details/6083375 =========================================== ...
- applicationContext.xml文件配置模板
<?xml version="1.0" encoding="gb2312"?><!-- Spring配置文件的DTD定义-->< ...