w3resource

Python Calendar Module: yeardayscalendar() method

yeardayscalendar() method

The yeardayscalendar() method is used to get the data for the specified year ready for formatting. The method is similar to yeardatescalendar().
Entries in the week lists are day numbers. Day numbers outside this month are zero.

Syntax:

yeardayscalendar(year, width=3)

Parameters:

Name Description Required /
Optional
Type
year Year for which the calendar should be generated. Required Number
width The number of months to include in each row. Default: 3 Required Number

Example of yeardayscalendar() method

import calendar
cal= calendar.Calendar()
print(cal.yeardayscalendar(2016, 5))

Output

[[[[0, 0, 0, 0, 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]], 
[[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, 0, 0, 0, 0, 0, 0]], 
............................
[[0, 0, 0, 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, 0]]]]

Previous: yeardays2calendar()
Next: formatmonth()

Test your Python skills with w3resource's quiz



Python: Tips of the Day

What is the difference between Python's list methods append and extend?

append: Appends object at the end.

x = [1, 2, 3]
x.append([4, 5])
print (x)

Output:

[1, 2, 3, [4, 5]]

extend: Extends list by appending elements from the iterable.

x = [1, 2, 3]
x.extend([4, 5])
print (x)

Output:

[1, 2, 3, 4, 5]

Ref: https://bit.ly/2AZ6ZFq