Jun-26-2020, 07:48 PM
Although I have been programming since 1956, I can't get beyond simple things in Python, in particular, getting data into and out of files.
I opened a file ('a'), and wrote 2 lines in it, acknowledged by the character count.
Closed it, opened it to read, but reading produces blank output:
I opened a file ('a'), and wrote 2 lines in it, acknowledged by the character count.
Closed it, opened it to read, but reading produces blank output:
tf = open('testfile.txt', 'a') tf.write('line1') tf.write('line2') tf.close tg = open('testfile.txt', 'r') print(tg.read()) tg.closeThe print command gives me a blank line. What am I doing wrong?