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 ...
随机推荐
- bootstrap's plugin:sthe usage of carousel
if we want use the carousel.js,we need quote it in the page. sample code: <div id="myCarouse ...
- java 强弱引用
ava中,虽然不需要程序员手动去管理对象的生命周期,但是如果希望某些对象具备一定的生命周期的话(比如内存不足时JVM就会自动回收某些对象从而避免OutOfMemory的错误)就需要用到软引用和弱引用了 ...
- 在线的代码托管平台 coding.net ===中国扩展版github
coding.net 是国内新兴的一个项目管理平台,功能主要包括:代码托管.在线运行环境.监控代码质量,兼有一定的社交功能. 在线运行环境支持Java.Ruby.Node.js.PHP.Python. ...
- sphinx分域搜索【不】需要在conf文件中使用sql_field_string
请看sql_field_string的文档说明: # combined field plus attribute declaration (from a single column) # stores ...
- HTTP状态码 - HTTP Status Code
HTTP Status Code 常见的状态码: HTTP: Status 200 – 服务器成功返回网页HTTP: Status 404 – 请求的网页不存在HTTP: Status 503 – 服 ...
- spring MVC之返回JSON数据(Spring3.0 MVC)
方式一:使用ModelAndView的contentType是"application/json" 方式二:返回String的 contentType是&qu ...
- Changing a remote's URL
原文: https://help.github.com/articles/changing-a-remote-s-url/ Changing a remote's URL MAC WINDOWS LI ...
- push控制器 卡顿
代码: RecommendController *rec = [[RecommendController alloc]init]; [self.navigationController pushVie ...
- UIApplication 用法解析
UIApplication,代表的是整个应用做的事,因此每个程序只能有一个,系统使用的是单例模式,就是上面的[UIApplication sharedApplication]来得到一个实例.这个单例实 ...
- WINCE下进程间通信(一)
WINCE下进程间通信(一) 在WINCE开发中经常需要在不同的进程之间传递.共享数据,总结了一下,WINCE下进程间通信常用的方式有:Windows消息,共享内存,socket通信,管道,全局原子, ...