Answer the question
In order to leave comments, you need to log in
How to change the type of dates in the list?
There is a list:
a = ['12.12.2020', '13.12.2020', '15.10.2020', '16.12.2020', '20.08.2020']
b = ['2020-12-12', '2020-12-13', '2020-10-15', '2020-12-16', '2020-08-20']
Answer the question
In order to leave comments, you need to log in
That's all the basics, let's do it yourself.
https://docs.python.org/3/library/datetime.html#da...
https://docs.python.org/3/library/datetime.html#da...
or just split by dot and reassemble
Option with intermediate conversion to date:
import datetime
b = list(map(lambda x: datetime.datetime.strptime(x, '%d.%m.%Y').strftime('%Y-%m-%d'), a))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question