Advertisement
andreymal

Python get current week

Dec 20th, 2017
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import calendar
  5. from datetime import datetime
  6.  
  7.  
  8. def get_week():
  9.     date = datetime.today()
  10.     for week in calendar.monthcalendar(date.year, date.month):
  11.         if date.day in week:
  12.             return week
  13.  
  14.  
  15. print(get_week())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement