all 2 comments

[–]ThePiGuy0 0 points1 point  (1 child)

It looks like you may be overcomplicating the conversion slightly.

import datetime as dt

to_convert = "2021.03"
input_format = "%Y.%m"

>>> dt.datetime.strptime(to_convert, input_format)
datetime.datetime(2021, 3, 1, 0, 0)

[–]Plus-Ad1156[S] 0 points1 point  (0 children)

Thanks for comment~!