I'm using Python 2.7.
I have a datetime object:
mytime = 2016-02-16 16:01:52.619388+00:00
I need to convert it to unicode in the following format:
unicode_time = u'2016-02-16T15:34:14.825878Z'
The way I accomplish this:
unicode_time = unicode(datetime.isoformat(mytime)).replace('+00:00', 'Z')
However, I don't like calling the .replace() method, it feels hacky to me. Is there a better way to do this? (that is supported with datetime module maybe)