简体   繁体   中英

how would I parse this with datetime(python)

{'dateTime': '2020-12-31T08:00:00-05:00'}

my attempt:

start = "{'dateTime': '2020-12-31T08:00:00-05:00'}"
start_obj = datetime.datetime.strptime(start, "{'dateTime': '%Y-%m-%dT%I:%M:%S-05:00'}"
print(start_obj)
import datetime

dates = {'dateTime': '2020-12-31T08:00:00-05:00'}
start_obj = datetime.datetime.strptime(dates['dateTime'], "%Y-%m-%dT%I:%M:%S%z")
print(start_obj)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM