I have certain time values in excel as :
Data:
932
1253
5
Coversions:
When trying to process them as a time string I get:
TIME_FMT= "%H%M"
datetime.strptime('932',TIME_FMT).time()
# Output : datetime.time(9, 32)
datetime.strptime('1253',TIME_FMT).time()
# Output : datetime.time(12, 53)
datetime.strptime('5',TIME_FMT).time()
# Output : ValueError: time data '5' does not match format '%H%M'
How can I catch such exceptional values for normal processing?
I understand that 5 does not match the format "%H%M".