StringIO in Python3

后端 未结 8 1891
清酒与你
清酒与你 2020-11-22 13:33

I am using Python 3.2.1 and I can\'t import the StringIO module. I use io.StringIO and it works, but I can\'t use it with numpy\'s

8条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 14:30

    You can use the StringIO from the six module:

    import six
    import numpy
    
    x = "1 3\n 4.5 8"
    numpy.genfromtxt(six.StringIO(x))
    

提交回复
热议问题