如何将字符串转换为具有相关时区的python datetime对象?

如何将字符串转换为具有相关时区的python datetime对象?,python,datetime,Python,Datetime,我有一个类似于“2012-06-14 20:38:24.213-7:00”的字符串,我想将其转换为一个时区保持不变的python日期时间对象,我该怎么做 否则和/或库可能会有所帮助: >>> from dateutil import parser >>> parser.parse('2012-06-14 20:38:24.213-7:00') datetime.datetime(2012, 6, 14, 20, 38, 24, 213000, tzinfo=t

我有一个类似于“2012-06-14 20:38:24.213-7:00”的字符串,我想将其转换为一个时区保持不变的python日期时间对象,我该怎么做

否则和/或库可能会有所帮助:

>>> from dateutil import parser
>>> parser.parse('2012-06-14 20:38:24.213-7:00')
datetime.datetime(2012, 6, 14, 20, 38, 24, 213000, tzinfo=tzoffset(None, -25200))

否则和/或库可能会有所帮助:

>>> from dateutil import parser
>>> parser.parse('2012-06-14 20:38:24.213-7:00')
datetime.datetime(2012, 6, 14, 20, 38, 24, 213000, tzinfo=tzoffset(None, -25200))