Python Calendar Module: itermonthdays() method
itermonthdays() method
The itermonthdays() method returns an iterator of a specified month and a year. Days returned will simply be day numbers. The method is similar to itermonthdates().
Syntax:
itermonthdays(year, month)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
year | Year for which the calendar should be generated. | Required | Number |
month | Month for which the calendar should be generated. | Required | Number |
Example of itermonthdays() method
import calendar
cal= calendar.Calendar()
for x in cal.itermonthdays(2016, 5):
print(x)
Output:
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 0 0 0 0
Note: itermonthdates: Return an iterator for the month month (1-12) in the year year. This iterator will return all days (as datetime.date objects) for the month and all days before the start of the month or after the end of the month that are required to get a complete week.
Previous: itermonthdays2()
Next: monthdatescalendar()
Test your Python skills with w3resource's quiz
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python/module/calendar/itermonthdays.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics