With Python 3.6 you can use:
from datetime import datetime
datetime.utcnow().isoformat(sep=' ', timespec='milliseconds')
Output:
'2019-05-10 09:08:53.155'
More info here: https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat