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

see What’s New In Python 3.0

AttributeError: type object '_io.StringIO' has no attribute 'StringIO'的更多相关文章

  1. 重写用户模型时报错AttributeError: type object ‘自定义类’ has no attribute ‘USERNAME_FIELD’

    view中导入:from django.contrib.auth.models import AbstractBaseUser settings.py中设置了:AUTH_USER_MODEL='app ...

  2. Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'

    报错场景 执行   celery worker -A tasks -l INFO  打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...

  3. 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_ ...

  4. AttributeError type object 'deprecated' has no attribute 'ROCKY'

    AttributeError type object 'deprecated' has no attribute 'ROCKY' 在使用kolla安装docker的时候遇到了AttributeErro ...

  5. AttributeError: type object 'testClass' has no attribute 'testMothod'

    点击"Unittest for test_post_API.testClass"按钮,点击”Edit configuration...“,弹出对话框Run/Debug config ...

  6. 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 ...

  7. Rasa init报错:AttributeError: type object 'Callable' has no attribute '_abc_registry'

    错误:Rasa init --no-prompt 报错 原因:Python升级到3.7后会遇到该问题 解决:pip uninstall typing

  8. AttributeError: 'list' object has no attribute 'write_pdf'

    我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...

  9. AttributeError: 'WebElement' object has no attribute 'send_keys'

    这个是没问题的代码:用来打开谷歌搜索cheese并退出 from selenium import webdriver from selenium.common.exceptions import Ti ...

随机推荐

  1. Windows And Video Memory

    MSDN Blogs > Zemblanity > Windows And Video Memory   Windows And Video Memory Tom_Mulcahy 11 F ...

  2. ORA-00942:table or view does not exist

    好好的表都建成功了,在PL/SQL中编辑数据时给我来这个提示,起的我没办法了.查到如下: oracle建表时有一个严重的问题,在此写出来,提醒大家注意: 先简单写一下错误内容,如各位已经发现过此问题并 ...

  3. js对象详解

    js自定义对象 一,概述 在Java语言中,我们可以定义自己的类,并根据这些类创建对象来使用,在Javascript中,我们也可以定义自己的类,例如定义User类.Hashtable类等等. 目前在J ...

  4. angular2 笔记

    动态添加一个component: import { ViewContarinerRef, Component, ComponentFactoryResolver, ViewChild } from ' ...

  5. hadoop 集群跑的时候用到hbasejar 文件的引用问题

    1. 创建软连接 ln -s /home/hadoop/bigdater/hbase-0.98.6-cdh5.3.6/conf/hbase-site.xml ./hbase-site.xml(记得这里 ...

  6. 零基础如何自学MySQL数据库?

    作者:姜健链接:https://www.zhihu.com/question/34840297/answer/67536521来源:知乎著作权归作者所有,转载请联系作者获得授权. 本人是个活生生的例子 ...

  7. Cocos2d-x 3.x 错误 cocos2dxDownloader 编译报错

    因为自带的库不是自己写的代码,所以报错的当时就傻了 报错文件为Cocos2dxDownloader.java 错误铺满全屏,仔细查看发现是类的调用有问题,翻到最上边发现是有几个(很多个)类没有定义,我 ...

  8. MongoDB学习笔记七:管理

    [启动和停止MongoDB]『从命令行启动』执行mongod,启动MongoDB服务器.mongod有很多可配置的启动选项:在命令行运行mongod --help可以查看所有选项.一些主要选项如下: ...

  9. 3数字cn域名延续数字域名火爆行情! 珍品域名 593.cn 出售

      近日, 域名投资者小维放出珍藏多年的珍品域名593.cn, 据悉该域名将参加易名中国举办的数字域名专场拍卖活动,将以1元标价起拍.   域名593.cn,数字“593”谐音“我就上.吾就上.我就商 ...

  10. vim中添加多行注释和删除多行注释

    1.多行注释:   a. 按下Ctrl + v,进入列模式;   b. 在行首选择需要注释的行;   c. 按下"I",进入插入模式:  d. 然后输入注释符("//&q ...