How to parse timezone with colon

后端 未结 3 1914
情歌与酒
情歌与酒 2021-01-03 18:07

Is there a way to parse timezone in \"+00:00\" format with datetime.strptime? For instance:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:4         


        
3条回答
  •  礼貌的吻别
    2021-01-03 18:37

    Another solution is to use the dateutil library:

    from dateutil import parser
    
    mystr = '2015-04-30T23:59:59+00:00'
    
    x = parser.parse(mystr)
    
    # 2015-04-30 23:59:59+00:00
    

提交回复
热议问题