Converting string into datetime object in Python

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

import datetime as dt

# tday = dt.date.today()
# print(tday.month, tday.year)

date_str = "10AM August 9, 2023"
date_dt = dt.strptime(date_str, "%H %B %d, %Y")
print(date_dt)


AttributeError: module 'datetime' has no attribute 'strptime'

Prakhar_Choubey
Автор

Let's say I have '2021-10-24'. Now how can I convert it?

San_desh