AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
python2导入StringIO模块,直接:
from StringIO import StringIO
对于python3,StringIO和cStringIO模块已经没了,如果要使用的话,需要导入io模块:
from io import StringIO
dot_data = StringIO()
你也可以导入six模块来使用StringIO:
from six import StringIO
或
from sklearn.externals.six import StringIO
例子:对于python2和python3都兼容:
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
REF.
[1]http://stackoverflow.com/questions/11914472/stringio-in-python3
[2]https://github.com/pgbovine/OnlinePythonTutor/issues/111
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'的更多相关文章
- 重写用户模型时报错AttributeError: type object ‘自定义类’ has no attribute ‘USERNAME_FIELD’
view中导入:from django.contrib.auth.models import AbstractBaseUser settings.py中设置了:AUTH_USER_MODEL='app ...
- Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'
报错场景 执行 celery worker -A tasks -l INFO 打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...
- ddt运行测试方法时报错AttributeError: type object 'TestHttpRq' has no attribute 'test_http_rq_login'
import unittest import ddt #装饰器 from ddt import ddt,data,unpack #导入ddt中的各个模块 from homework.unittest_ ...
- AttributeError type object 'deprecated' has no attribute 'ROCKY'
AttributeError type object 'deprecated' has no attribute 'ROCKY' 在使用kolla安装docker的时候遇到了AttributeErro ...
- AttributeError: type object 'testClass' has no attribute 'testMothod'
点击"Unittest for test_post_API.testClass"按钮,点击”Edit configuration...“,弹出对话框Run/Debug config ...
- ddt运行报错AttributeError: type object 'TestLogin' has no attribute 'test_login'
源代码: #!usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2018/12/17 下午2:07 # @File: do_excel.py # @Sof ...
- Rasa init报错:AttributeError: type object 'Callable' has no attribute '_abc_registry'
错误:Rasa init --no-prompt 报错 原因:Python升级到3.7后会遇到该问题 解决:pip uninstall typing
- AttributeError: 'list' object has no attribute 'write_pdf'
我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...
- AttributeError: 'WebElement' object has no attribute 'send_keys'
这个是没问题的代码:用来打开谷歌搜索cheese并退出 from selenium import webdriver from selenium.common.exceptions import Ti ...
随机推荐
- Bootstrap模态弹出窗
Bootstrap模态弹出窗有三种方式: 1.href触发模态弹出窗元素: <a class="btn btn-primary" data-toggle="moda ...
- C语言基础回顾
第一章 C语言基础 1. C语言编译过程 预处理:宏替换.条件编译.头文件包含.特殊符号 编译.优化:翻译并优化成等价的中间代码表示或汇编代码 汇编:生成目标文件,及与源程序等效的目标的机器语言代码 ...
- Socket实现粗略的Android聊天功能
面试时写过,但是很乱,今天看到代码库里有一个,还是很规范的,贴出来. 主要用到俩类,一个是ServerSocket.class 一个是Socket.class. 记得要加权限: <uses-p ...
- 用bugzilla统计BUG
bugzilla—— reports—— Tabular reports—— 选择版本号啥的跟search一样 上面的行标Vertical Axis选Resolution:列标Horizontal A ...
- 《我是一只IT小小鸟》读书笔记
大一进来的第一个学期 我对我所读的软件工程专业感到迷茫与不知.就这么昏昏沉沉的度过了一个学期,第二个学期一开始,在上第一节新增加的“大学生创业与指导”课程充满了好奇,在课上老师推荐的一本书<我是 ...
- 打造IE6的position:fixed整理篇
fixed真的是一个很好的属性.特别是做弹层的时候.可惜的是“国内主流浏览器”IE6大大不支持. 一般的我们都会通过CSS中的表达式来解决这个问题. .fixed { position:absolut ...
- C# 实现软件的重启
有些时候我们想用户在设置完之后使程序重新启动生效,这时候我们只需要简单的应用一下代码即可: if (MessageBox.Show("设置保存成功,下次启动时生效,是否马上重启软件?&quo ...
- VMvare克隆复制多个操作系统
目的:完成linux的双机和集群实验 2016-12-06 在网上查找了一些资料现整理如下,以供之后查看和帮助他人. 注意事项: 1.关闭源虚拟机的电源: 操作很简单 选择完整创建 输入源克隆机的用户 ...
- iOS、swift、React Native学习常用的社区、论坛
<!----iOS> <!----Swift>*IOS开发常用社区:http://code4app.com/ *IOS开发常用社区:http://www.cocoachina. ...
- Ajax在html页面获取后台XML文件资源
一.准备工具 站长吧ASP调试工具.exe,这个工具是为了快速建立asp环境,方便调试. 二.建立文件夹 1.建立网站根文件夹,名字随意,将站长吧ASP调试工具.exe复制到根文件夹: 2.建立xml ...