相关疑难解决方法(0)

如何在Python 2.7中使用StringIO解决TypeError?

尝试使用以下字符串作为文件读取以下字符串StringIO.我该如何解决?

>> from io import StringIO
>>>
>>> datastring = StringIO("""\
... Country  Metric           2011   2012   2013  2014
... USA     GDP               7      4     0      2
... USA     Pop.              2      3     0      3
... GB      GDP               8      7     0      7
... GB      Pop.              2      6     0      0
... FR      GDP               5      0     0      1
... FR      Pop.              1      1     0      5
... """)
Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
TypeError: initial_value must be unicode …
Run Code Online (Sandbox Code Playgroud)

python stringio python-2.7

24
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1

python-2.7 ×1

stringio ×1