Python Calendar.iterweekdays() 方法
Calendar.iterweekdays() 方法是内置的方法Calendar
类calendar
Python 中的模块。它使用此类的一个实例,并返回一个用于一周的工作日数字的迭代器。迭代器返回的第一个数字是为该实例设置的第一个工作日。默认情况下,first-weekday 集为 0,即星期一。
模块:
import calendar
类:
from calendar import Calendar
用法:
iterweekdays()
参数:
- None
返回值:
这个方法的返回类型是<class 'generator'>
,它返回工作日数字的迭代器,从该迭代器开始给出 7 个工作日数字。
例:
# Python program to illustrate the
# use of iterweekdays() method
# import module
import calendar
# Creating Calendar instance
cal = calendar.Calendar()
print("Iterating with first weekday as 0, ie, Monday")
for i in cal.iterweekdays():
print(i)
print()
# Changing firstweekday for the Calendar
cal = calendar.Calendar(firstweekday = 3)
# iterator starts with 3
print("Iterating with first weekday as 3, ie, Thursday")
for i in cal.iterweekdays():
print(i)
print()
输出
Iterating with first weekday as 0, ie, Monday 0 1 2 3 4 5 6 Iterating with first weekday as 3, ie, Thursday 3 4 5 6 0 1 2
相关用法
- Python Calendar itermonthdays2()用法及代码示例
- Python Calendar itermonthdates()用法及代码示例
- Python Calendar itermonthdays3()用法及代码示例
- Python Calendar itermonthdays4()用法及代码示例
- Python Calendar itermonthdays()用法及代码示例
- Python Calendar monthdatescalendar()用法及代码示例
- Python Calendar monthdayscalendar()用法及代码示例
- Python Calendar yeardatescalendar()用法及代码示例
- Python Calendar yeardayscalendar()用法及代码示例
- Python Calendar yeardays2calendar()用法及代码示例
- Python Calendar monthdays2calendar()用法及代码示例
- Python Condition release()用法及代码示例
- Python Collections.UserString用法及代码示例
- Python Condition notify()用法及代码示例
- Python Condition wait()用法及代码示例
- Python Sympy Curve.translate()用法及代码示例
- Python Collections.UserDict用法及代码示例
- Python Collections.UserList用法及代码示例
- Python Condition notify_all()用法及代码示例
- Python Condition acquire()用法及代码示例
注:本文由纯净天空筛选整理自 Python Calendar Class | iterweekdays() Method with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。