formatmonth()

Calendar Module

theyearYear number for which calendar of the month is returned
themonthMonth number for which calendar of the month is returned
wOptional , default =0 , width of date column
lOptional , default =0 , number of line each week will use
formatmonth() : Returns a string of Monthly calendar .

import calendar
x=calendar.TextCalendar() # 
print(x.formatmonth(theyear=2020,themonth=7,w=3,l=0))
Output
         July 2020
Mon Tue Wed Thu Fri Sat Sun
          1   2   3   4   5
  6   7   8   9  10  11  12
 13  14  15  16  17  18  19
 20  21  22  23  24  25  26
 27  28  29  30  31
Based on the setting of first day of the week, the calendar first weekday can be set. Week day number starts from 0 as Monday , 1 as Tuesday and ends at 6 as Sunday.
import calendar
x=calendar.TextCalendar() 
x.setfirstweekday(4) # first week day is Friday
print(x.formatmonth(theyear=2020,themonth=7,w=3,l=0))
Output
         July 2020
Fri Sat Sun Mon Tue Wed Thu
                      1   2
  3   4   5   6   7   8   9
 10  11  12  13  14  15  16
 17  18  19  20  21  22  23
 24  25  26  27  28  29  30
 31
Calendar Module in Python itermonthdays() itermonthdays2() itermonthdays3()




plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer