I cannot seem to write time/date to the file.

Steve Gronicus at SGA.Ninja
Tue Feb 12 14:19:48 EST 2019


I am using nowTimeDate2 elsewhere in my program and it can be printed to the screen.

The file exists and the program successfully opens the file, writes to it, and closes the file.

All is working as designed.

 

However,

Now I want to place an entry into the first line of the file to note the time/date the file was created.
It doesn’t show up in the file.

How do I fix this?

 

from time import gmtime, strftime 

nowTimeDate2=strftime("%Y %a %b %d %H:%M") 

print(nowTimeDate2)  #This works

DateReading=open("Date-ReadingsAndDoses.txt", "w")

DateReading.write = (nowTimeDate2 + "\n")

DateReading.close()

 

I also tried to append but that did not work either.

Interestingly enough, this is a feature that really has no real purpose in the final product yet it is hounding me.

 

 

 

Footnote:

 <http://click1.email.theonion.com/fdhhznrjhrcwhhsdwbqczwybqhwgsbrpzdlbfybhqbhhj_bjcgpjgcpypgjzzbfqdd.html?a=TheOnion_Daily_RSS&b=&c=> Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

 




More information about the Python-list mailing list