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. 关于asp.net的一点小问题有谁帮忙解答一下?

    public IList<Category> Categories { get; set; }        protected void Page_Load(object sender, ...

  2. 1.2 ASSEMBLY LANGUAGE

    People are much happier moving up the ladder,socially or even technically.So our profession has move ...

  3. noConflict

    var _avalon = window.avalon avalon.noConflict = function(deep) { if (deep && window.avalon = ...

  4. php判断post数据是否存在(or 为空)的方法

    最近开发的php项目用到了表单 所以需要响应post请求 而在实际使用中 有些请求只需判断是否存在 百度了不少资料 发现都比较繁杂 然后想起了  count()函数 — 计算数组中的单元数目或对象中的 ...

  5. 嵌入式(Embedded)Neo4j数据库访问方法

    应用中采用嵌入式Neo4j(Embedded Neo4j)数据库,插入数据后不知道如何访问.查询之后知道有Neoclipse这个可视化工具,最新版本是1.9.5.添加目录后报错: 应该是Neoclip ...

  6. 转战网站后台与python

    这么长时间了,迷茫的大雾也逐渐散去,正如标题所写的一样,转战网站后台开发.这段时间没怎么写博客,主要还是太忙,忙着期末考试的预习,以及服务器的搭建,python的学习,还有各种各样杂七杂八的小事,就像 ...

  7. Kindle Unlimited上的技术书籍

            直达链接:Kindle Unlimited         前不久,亚马逊在中国也推出了电子书包月服务.消息不灵通的我过了好久才看到这个消息,随后第一时间上官网查看具体情况.      ...

  8. jQuery 简介

    jQuery 简介 jQuery 库可以通过一行简单的标记被添加到网页中. jQuery 库 - 特性 jQuery 是一个 JavaScript 函数库. jQuery 库包含以下特性: HTML ...

  9. 利用html5的localStorage做一个备忘录

    实现一个便签功能,可以记录内容和写的时间,当网页从新载入,可以读取以前的记录. html文档 <!DOCTYPE html> <html> <head lang=&quo ...

  10. easyui datagrid 动态添加columns属性

    公司在项目设计的时候,有一个需求,就是查出来的表的字段不唯一,一张表的字段可能是三个,也可能是五个,但是却要把它显示到页面,这个给我做ui的带来一点麻烦.因为以前一般用easyui 的datagrid ...