TypeError: descriptor 'strftime' requires a 'datetime.date' object but received a 'Text'

后端 未结 2 772
轻奢々
轻奢々 2020-12-20 11:22

I have a variable testeddate which has a date in text format like 4/25/2015. I am trying convert it to %Y-%m-%d %H:%M:%S as follows:



        
2条回答
  •  盖世英雄少女心
    2020-12-20 12:01

    A less elegant solution would involve manipulating the string directly.

    testeddate = '4/25/2015'
    month, day, year = testeddate.split('/')
    testeddate = '-'.join([year, month, day]) + ' 00:00:00'
    

提交回复
热议问题