문제

I'm parsing datetimestamps using python dateutil, but would like to avoid the extra dependency. So Is there a way to do the equivalent with the standard python library:

dateutil.parser.parse("2012-12-12T12:00")

Thanks a lot!

도움이 되었습니까?

해결책

If your date strings are all in the same format, you could use strptime like this:

In [31]: import datetime as DT

In [32]: DT.datetime.strptime("2012-12-12T12:00", '%Y-%m-%dT%H:%M')
Out[32]: datetime.datetime(2012, 12, 12, 12, 0)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top