How do I parse an ISO 8601-formatted date?

后端 未结 27 2380
小鲜肉
小鲜肉 2020-11-21 06:08

I need to parse RFC 3339 strings like \"2008-09-03T20:56:35.450686Z\" into Python\'s datetime type.

I have found strptime in the Python sta

27条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 06:28

    If you are working with Django, it provides the dateparse module that accepts a bunch of formats similar to ISO format, including the time zone.

    If you are not using Django and you don't want to use one of the other libraries mentioned here, you could probably adapt the Django source code for dateparse to your project.

提交回复
热议问题