Dec-30-2017, 10:24 AM
(This post was last modified: Dec-30-2017, 10:24 AM by flatman123.)
Hello
i'm trying to read multiple lines in a file and it doesn't seem to work when I assigned my readline() method to a variable( it keeps printing the first line). It only seems to work when i don't assign it to a variable ..any ideas?
heres my code:
# i'm using Python 3.6.2
i'm trying to read multiple lines in a file and it doesn't seem to work when I assigned my readline() method to a variable( it keeps printing the first line). It only seems to work when i don't assign it to a variable ..any ideas?
heres my code:
# i'm using Python 3.6.2
# Here is it not working gradesfile = open(gradesfile_path,'r') readgrades = gradesfile.readline() print(readgrades) '*Assigne 1 grades\n' # This is the output print(readgrades) '*Assigne 1 grades\n' # This is the output # Here is it working when i don't call the variable print(gradesfile.readline()) '*Assigne 1 grades\n' # This is the output print(gradesfile.readline()) '*Columns\n' # This is the output print(gradesfile.readline()) '*ID\t grade\n' # This is the output