0 votes
1 view
in Python by (47.8k points)

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 standard library, but it is not very convenient.

What is the best way to do this?

1 Answer

0 votes
by (107k points)

To parse an ISO 8601-formatted date in Python you can use, the %f character, which can catch microseconds:-

import datetime

datetime.datetime.strptime("2008-09-03T20:56:35.450686Z", "%Y-%m-%dT%H:%M:%S.%fZ")

image

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...