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 ...
随机推荐
- ajax登陆提示
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Con ...
- REDIS 字典数据结构
对于REDIS来讲 其实就是一个字典结构,key ---->value 就是一个典型的字典结构 [当然 对于vaule来讲的话,有不同的内存组织结构 这是后话] 试想一个这样的存储场景: ...
- eclipse导入项目前面有感叹号
1.项目上右击---build path---Config..----Libra----
- tornado中self.write() 写list
tornado源码中不支持在self.write()中直接传入list对象,源代码如下 def write(self, chunk): if self._finished: raise Runtime ...
- 2015.10.18 do while练习
/*乘法表*/ #define COLMAX 10 #define ROWMAX 12 main() { int row,column,y; row=1; printf(" ...
- RadioButtonList的使用
前台绑定: <asp:RadioButtonList ID="hlBatchYuJi" runat="server" RepeatColumns=&quo ...
- rigidbody2D.velocity 提示缺少using?用的unity5?
请用 GetComponent<Rigidbody2D>().velocity
- Linux下压缩mp3文件
apt-get install lame lame -b 64 a.mp3 b.mp3 lame是压缩mp3的一个小工具 参数 -b 64 是输出文件的采样率64 a.mp3 是源文件 b.mp3 是 ...
- HttpClient封装工具类
import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; ...
- 利用IIS管理器模拟CDN
CDN(Content Delivery Network,内容分发网络).其含义,在百度百科上是这么写的:CDN 是构建在数据网络上的一种分布式的内容分发网.CDN 的作用是采用流媒体服务器集群技术, ...