Hi All,
My apologies in advance if my code is sloppy, just getting back into programming from a LONG break.
I'm having some trouble with datetime.strptime module in my Python3 script - which is running on a Raspberry Pi 3. I keep getting the error 'ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S.%f''
The trouble code in my script is as follows-
- TD
My apologies in advance if my code is sloppy, just getting back into programming from a LONG break.
I'm having some trouble with datetime.strptime module in my Python3 script - which is running on a Raspberry Pi 3. I keep getting the error 'ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S.%f''
The trouble code in my script is as follows-
from datetime import datetime, timedelta if os.path.isfile(log_file): # First check if file exists. with open(log_file, 'r') as f: date = f.read() date_to_datetime = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") if datetime.now() < date_to_datetime + timedelta(minutes=1): return # Update the email log. with open(log_file, 'w') as f: f.write(str(datetime.now()))Any and all help would be greatly appreciate. If you have a suggestion on how to fix my issue, please revise my code so it's as straight forward for me to understand as best as possible. Thank you!
- TD