I'm scraping some data and I got this format of date: February 23rd and would like to change it to 2021-02-23 using Python.
Thanks in advance
I'm scraping some data and I got this format of date: February 23rd and would like to change it to 2021-02-23 using Python.
Thanks in advance
I recommend using the dateutil module for parsing strings into dates that have non-standard formats that otherwise strftime
could handle
from dateutil.parser import parse
print(parse('February 23rd'))
>>> 2021-02-23 00:00:00
Since the year is missing from the input, parse
defaults to current year