def format_my_nanos(nanos):
    dt = datetime.datetime.fromtimestamp(nanos / 1000000000.0)
return '{}.{:09.0f}'.format(dt.strftime('%Y-%m-%dT%H:%M:%S'), nanos % 
    1000000000.0)
Python - Convert epoch time with nanoseconds to human-readable?