2020年12月15日星期二

Python strptime()

 Python strptime()

parsing-non-zero-padded-timestamps-in-python 

datetime.strptime():  creates a datetime object from the given string.

 

from datetime import datetime

dt_string = "12/11/2018 09:15:32"

dt_object1 = datetime.strptime(dt_string, "%d/%m/%Y %H:%M:%S")

dt_object2 = datetime.strptime(dt_string, "%m/%d/%Y %H:%M:%S")

没有评论: