Thanks a lot. This works!!!
• 0 views
•
link
For the following code in python, I am getting the error--AttributeError: 'str' object has no attribute 'next'
InFile = open(GffFile, 'rU')
i = 1
for line in InFile:
print line
if line.startswith("#"):
line.next()
Where is the error in code?
Please help me to solve issue.
The method next() is used when a file is used as an iterator. This method returns the next input line, or raises StopIteration when EOF is hit. You should call next() on file object and not the line (string). In your case it should be line = InFile.next() and not line.next()
Thanks a lot. This works!!!
Log in to answer this question.