python convert datetime formatted string to seconds
问题 I am trying to decode a date string to epoch but I have difficulties getting the timezone. This is the last modified date from Amazon S3 keys. time.strptime(key.last_modified, '%Y-%m-%dT%H:%M:%S.%Z') ValueError: time data u'2013-10-20T00:41:32.000Z' does not match format '%Y-%m-%dT%H:%M:%S.%Z' If I get rid of the timezone (.000Z) it works, but I need the timezone as well. 回答1: The .000Z is not recognized as a timezone offset. In fact, you have milliseconds and a timezone ( Z is UTC), and