Python datetime.strptime() Error: 'time data '' does not match format '%Y-%m-%d %H:%M:%S''
This error occurs when the value of tdopTimeStart is an empty string. The datetime.strptime() function expects a non-empty string that matches the specified format ('%Y-%m-%d %H:%M:%S').
To fix this error, you should check the value of tdopTimeStart and make sure it is not an empty string before trying to parse it as a datetime object. You can add an if statement to handle this case:
if tdopTimeStart:
start_datetime = datetime.strptime(tdopTimeStart, '%Y-%m-%d %H:%M:%S')
else:
# Handle the case when tdopTimeStart is an empty string
# For example, you can assign a default value to start_datetime or raise an exception.
Alternatively, you can validate the input before passing it to datetime.strptime() to ensure it is a valid datetime string.
原文地址: https://www.cveoy.top/t/topic/mkYV 著作权归作者所有。请勿转载和采集!