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. Oracle导出表(即DMP文件)的两种方法

    转载:http://blog.csdn.net/lanpy88/article/details/7580691   方法一:利用PL/SQL Developer工具导出: 菜单栏---->Too ...

  2. 最近开发的ECG项目

    最近参与公司开发了一款读取ECG心电接口程序 原理就是通过心电设备读取患者的心电数据 并生成ECG文件 然后通过ECG客户端程序读取ECG文件 并解析转换成图片 上传至服务器 下边是客户端程序截图 客 ...

  3. LPTHW 结束了

    基本上在学习了LPTHW的 类 继承 和 合成以后基本就结束. 后面几章都是根据web.py进行网页编程,以及自动化测试的.目前来看不太感兴趣. 稍后我可能找个实际项目进行锻炼下,比如 Crossin ...

  4. 长平狐 Android-x86虚拟机安装配置全攻略

    Android-x86虚拟机安装配置网上有很多,但是全部说明白的确不多,希望这篇文章能把主要的配置介绍给您,帮助您少走一些弯路. 本文分别针对VMWare和Virtual Box两种虚拟机介绍安装配置 ...

  5. Pixel VS Point, FrameBuffer VS RenderBuffer

    // How iOS app MVC works View, Window, AppDelegate ViewController, RootViewController // On Pixel VS ...

  6. js操作做GridView

    一:获取当前选中行的数据 function fun_selectedInfo() { //获取当前鼠标选中元素 var e=event.srcElement; //获取当前元素所在行号 var row ...

  7. it小小鸟

    It小小鸟观后感 每个人的理想目标都是不同的,很多人有自己的理想.却被困于现实而止步不前.一篇<it小小鸟>让我却懂得,一个人如果想有所作为,就不能止步不前.光有一个远大的理想是然并卵的. ...

  8. CSS code

    body{ background-color: #1b1919; background-image: url(); } #blog_nav_rss, #blog_nav_rss_image{ disp ...

  9. chosen组件实现下拉框

    chosen组件用于增强原生的select控件,使之有更好的用户体验.官方demo https://harvesthq.github.io/chosen/ 目前项目中碰到的使用,比如一个页面中有两个不 ...

  10. Linux中MySQL的基本操作

    1. 用root用户登录mysql mysql -u root -p 2. 查看database show databases; 3. 查看table use database名 show table ...