0

I am trying to parse my date string with time library. But i have an error in parsing.

# Example is 'In 0 days 23:07:56'
client['license_time_start'] = time.strptime('In 0 days 23:07:56', 'In %d days %H:%M:%S')

ValueError: time data 'In 00 days 23:07:56' does not match format 'In %d days %H:%M:%S'

Oleg
  • 25
  • 1
  • 5

1 Answers1

2

The error is because date can't be 0. It has to be an positive integer.

Therefore, this produces an error:-

time.strptime('In 0 days 23:07:56', 'In %d days %H:%M:%S')
# ValueError: time data 'In 0 days 23:07:56' does not match format 'In %d days %H:%M:%S'

This doesn't:-

time.strptime('In 01 days 23:07:56', 'In %d days %H:%M:%S')
# time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=23, tm_min=7, tm_sec=56, tm_wday=0, tm_yday=1, tm_isdst=-1)
Vasu Deo.S
  • 1,820
  • 1
  • 11
  • 23