Я использую python 3.3.3. Я делаю учебник с tutorialspoint.com. Я не могу понять, что это за ошибка.
Вот мой код:
fo = open("foo.txt", "w")
print ("Name of the file: ", fo.name)
# Assuming file has following 5 lines
# This is 1st line
# This is 2nd line
# This is 3rd line
# This is 4th line
# This is 5th line
seq = ["This is 6th line\n", "This is 7th line"]
# Write sequence of lines at the end of the file.
fo.seek(0, 2)
line = fo.writelines( seq )
# Now read complete file from beginning.
fo.seek(0,0)
for index in range(7):
# line = fo.next()
print ("Line No %d - %s" % (index, line)+"\n")
# Close opend file
fo.close()
Ошибка:
Name of the file: foo.txt
Traceback (most recent call last):
File "C:/Users/DELL/Desktop/python/s/fyp/filewrite.py", line 19, in <module>
line = fo.next()
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'