Convert 12 hour time string into datetime or time

前端 未结 3 710
暗喜
暗喜 2021-01-16 08:03

Ive been trying to use time.strptime(string1,\'%H:%M\'), with no success

How can I get the following:

Input     Output
3:14AM  -> 03:         


        
3条回答
  •  春和景丽
    2021-01-16 08:21

    You're missing %p (Locale’s equivalent of either AM or PM).

    time.strptime(string1,'%H:%M%p')
    

提交回复
热议问题