python "AttributeError: '_csv.reader' object has no attribute'next'" error solution

I just started learning machine learning, and I was practicing the decision tree algorithm. I found that the following program was executed when importing the csv module. AttributeError: '_csv.reader' object has no attribute'next', I was worried for a long time and finally found a solution. Friends encounter similar problems and hope to help.

The code and error message are as follows:  


 



Solution:

Line 17: reader.next() is changed to next(reader), which seems to be related to the running version of python.

However, after running, there is a second worrying problem, as follows:



Solution:

Line 15: Change "rb" to "rt".

This is the first time to write a blog, if there are any mistakes, please feel free to correct them!

Reference link:

[1]:http://blog.csdn.net/qing101hua/article/details/77002444

[2]:https://www.kaggle.com/c/titanic/discussion/4937

  


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522178&siteId=291194637