Python ProgrammingPython Programming

How to find week of the year from 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.week_of_year)

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

dt = pendulum.parse('2018-01-21')
print(dt.week_of_year)
Output
21
48
3