Answer the question
In order to leave comments, you need to log in
ValueError: time data '2021-11-21' does not match format '%a %b %d %H:%M:%S %Y'?
today = date.today()
strftime("%Y-%m-%d", strptime(today.strftime('%Y-%m-%d')))
Answer the question
In order to leave comments, you need to log in
Can you explain what you are doing here?
today.strftime('%Y-%m-%d') - OK, of course, we translate the date into a string.
strptime(today.strftime('%Y-%m-%d')) - well, suppose we want to convert the string back to the "datatime" format. But without specifying the format parameter, you accept the default format "%a %b %d %H:%M:%S %Y"
And now the main question is
strftime("%Y-%m-%d", strptime(today .strftime('%Y-%m-%d'))) - where is the first parameter - data, where is the second parameter - format?
So I can only suspect that you meant to write something like
today = date.today()
datetime.strftime( datetime.strptime(today.strftime('%Y-%m-%d'),'%Y-%m-%d'),"%Y-%m-%d")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question