python readline() output nothing -


this question has answer here:

i got nothing command readline(). new python , totally confused now.

my_file = open("test.txt", "w+") my_file.write("this test") print my_file.readline() 

when write file, overwrite previous contents of file , leave pointer @ end of file. attempt read after fail, since you're @ end of file.

to reset beginning of file , read wrote, use:

my_file.seek(0) 

Comments