nofrag_dt = time.strptime(nofrag, '%Y-%m-%dT%H:%M:%S')
ts = datetime.datetime.fromtimestamp(time.mktime(nofrag_dt))
dt = ts.replace(microsecond=int(frag))
print(dt)
Python - Datetime not accounting for leap second properly?