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. ansible代码分析第一篇--主文件—ansible分析

    2016年2月23日,学习,分析ansible代码 ansible是一种运维中使用的批量部署的工具,它本身是一种框架,具体的部署和架构分析,下面这篇文章讲的不错. http://os.51cto.co ...

  2. Ubuntu Sublime Text 设置等宽字体

    { "font_face": "DejaVu Sans Mono", "font_size": 10, "word_wrap&qu ...

  3. tableView优化性能

    在iOS应用中,UITableView应该是使用率最高的视图之一了.iPod.时钟.日历.备忘录.Mail.天气.照片.电话.短信. Safari.App Store.iTunes.Game Cent ...

  4. 转载《SimpleAdapter的参数说明》

    SimpleAdapter的参数说明 第一个参数 表示访问整个android应用程序接口,基本上所有的组件都需要 第二个参数表示生成一个Map(String ,Object)列表选项 第三个参数表示界 ...

  5. C#的循环语句练习

    1.输入一个整数,算出从1到这个数每个数阶乘的和. 2.求100以内质数的和. 3.有一对幼兔,幼兔1个月后长成小兔,小兔1个月后长成成兔并生下一对幼兔,问几个月后有多少对兔子,幼兔,小兔,成兔分别是 ...

  6. ASP.NET Core (Database First)

    CREATE DATABASE [EFCore_dbfirst] GO USE [EFCore_dbfirst] GO CREATE TABLE [Blog] ( [BlogId] int NOT N ...

  7. PC windows mobile 文件拷贝

    在windows 系统中提供 RAPI.DLL,只需将RAPI.DLL中的,函数导出就可以实现文件拷贝.

  8. Sqlserver 函数(例子)

    --SQL SERVER 2008 函数大全/*author:TracyLeecsdncount:Travylee*/ /*一.字符串函数:1.ascii(字符串表达式)   返回字符串中最右侧字符的 ...

  9. java 反射的应用 以及通过反射 用到的工厂模式

    java反射详解 本篇文章依旧采用小例子来说明,因为我始终觉的,案例驱动是最好的,要不然只看理论的话,看了也不懂,不过建议大家在看完文章之后,在回过头去看看理论,会有更好的理解. 下面开始正文. [案 ...

  10. java验证码前台技术

    //下面是在前台jsp页面不用导工具的情况下制作的验证码的基本代码 $(function(){ //创建验证码 createCode(); jQuery.validator.addMethod( &q ...