Use the datetime.strptime method:
import datetime
datetime.datetime.strptime(your_string, "%Y-%m-%dT%H:%M:%S.%f")
The link provided presents the different format directives. Note that the microseconds are limited to the range [0,999999]
, meaning that a ValueError
will be raised with your example (you're using 1/10us): you need to truncate your string to drop the final character.