Python ProgrammingPython Programming

How to find day of the year of specific date in Python?

Use Pendulum module to solve Date time problems.
Install it using below command

pip install pendulum
import pendulum

dt = pendulum.parse('2015-05-18')
print(dt.day_of_year)

dt = pendulum.parse('2019-12-01')
print(dt.day_of_year)

dt = pendulum.parse('2018-01-21')
print(dt.day_of_year)
Output
138
335
21