AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
Posted xyq_idata
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
try: from StringIO import StringIO except ImportError: from io import StringIO
以上是关于AttributeError: type object '_io.StringIO' has no attribute 'StringIO'的主要内容,如果未能解决你的问题,请参考以下文章