Parse date string and change format

后端 未结 9 849
孤街浪徒
孤街浪徒 2020-11-22 00:58

I have a date string with the format \'Mon Feb 15 2010\'. I want to change the format to \'15/02/2010\'. How can I do this?

9条回答
  •  暖寄归人
    2020-11-22 01:38

    convert string to datetime object

    from datetime import datetime
    s = "2016-03-26T09:25:55.000Z"
    f = "%Y-%m-%dT%H:%M:%S.%fZ"
    out = datetime.strptime(s, f)
    print(out)
    output:
    2016-03-26 09:25:55
    

提交回复
热议问题