Random Tip

How to get the current week’s number 📅 in Python 🐍?

import datetime

today = datetime.date.today()
week = today.isocalendar()[1]

print(f'Today is {today}')
print(f'This week is Week {week}')

This would print

Today is 2022-08-09
This week is Week 32

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
%d bloggers like this: