reading and writing files function to obtain the current date and time you can use the str(function to convert this date time object into string so that it can be written out to file create second program to reload the date from the file and convert the string into date object you can use the datetime strptime(function to convert string into date time object (see datetime html#datetime datetime strptime for documentation on this functionthis functions takes string containing date and time in it and second string which defines the format expected if you use the approach outlined in step above to write the string out to file then you should find that the following defines an appropriate format to parse the date_str so that date time object can be createddatetime_object datetime strptime(date_str'% -% -% % :% :% % '