日历模块允许输出类似于程序的日历,并提供与日历相关的其他有用函数。 “日历”模块中定义的函数和类使用理想化的日历,当前的公历日历在两个方向上都无限期扩展。
itermonthdays()
方法返回指定月份和年份的迭代器。返回的天数仅仅是天数。itermonthdays()
方法类似于itermonthdates()
。
用法: itermonthdays(year, month) 参数: year: year of the calendar month: month of the calendar 返回: an iterator of the specified month.
代码1:
# Python program to demonstrate working
# of itermonthdays() method
# importing calendar module
import calendar
year = 2018
mnth = 9
obj = calendar.Calendar()
# iteratign with itermonthdays
for day in obj.itermonthdays(year, mnth):
print(day)
输出:
0 0 0 0 0 1 2 3 4 5 6 . . 29 30
代码2:
# Python program to demonstrate working
# of itermonthdays() method
# importing calendar module
import calendar
# use with firstweekday = 5
obj = calendar.Calendar(firstweekday = 2)
# iteratign with itermonthdays
for day in obj.itermonthdays(2018, 4):
print(day)
输出:
0 0 0 0 1 2 3 4 5 . . 28 29 30 0
相关用法
- Python calendar yeardatescalendar()用法及代码示例
- Python calendar yeardays2calendar()用法及代码示例
- Python calendar monthdayscalendar()用法及代码示例
- Python calendar monthdays2calendar()用法及代码示例
- Python calendar yeardayscalendar()用法及代码示例
- Python calendar leapdays()用法及代码示例
- Python calendar isleap()用法及代码示例
- Python calendar firstweekday()用法及代码示例
- Python calendar setfirstweekday()用法及代码示例
- Python calendar itermonthdates()用法及代码示例
- Python calendar itermonthdays2()用法及代码示例
- Python calendar formatmonth()用法及代码示例
- Python calendar prmonth()用法及代码示例
- Python calendar formatyear()用法及代码示例
- Python calendar pryear()用法及代码示例
注:本文由纯净天空筛选整理自Shivam_k大神的英文原创作品 Python calendar module | itermonthdays() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。