小编gou*_*ugh的帖子

如何将此代码从Python 2.7转换为Python 3.5以修复---> AttributeError:'_ io.TextIOWrapper'对象没有属性'next'

我使用的是Python 3.5,但本书正在教2.7(打败我为什么在2016年)

使用Python学习Predictive Analytics由Ashish Kumar于2016年2月15日

    >>> data=open(filename,'r')
    >>> cols=data.next().strip().split(',')
    Traceback (most recent call last):
      File "<pyshell#1>", line 1, in <module>
        cols=data.next().strip().split(',')
    AttributeError: '_io.TextIOWrapper' object has no attribute 'next'
    >>> 
Run Code Online (Sandbox Code Playgroud)

我已经读过这个 AttributeError:'_io.TextIOWrapper'对象没有属性'next'python ,我仍然不知道如何让它在Python 3.5 GUI shell中工作.

到目前为止,我理解Python 3.5我必须使用.__next__; 对于Python 2.7 .next.

python iterator python-2.7 python-3.x

2
推荐指数
1
解决办法
313
查看次数

标签 统计

iterator ×1

python ×1

python-2.7 ×1

python-3.x ×1