日曆模塊允許輸出類似於程序的日曆,並提供與日曆相關的其他有用函數。 “日曆”模塊中定義的函數和類使用理想化的日曆,當前的公曆日曆在兩個方向上都無限期擴展。
iterweekdays()方法返回將用於一周的星期幾的迭代器。迭代器的第一個數字將與firstweekday()返回的數字相同。
用法: iterweekdays() 參數: no parameter 返回: iterator for the week day numbers
代碼1:
# Python program to demonstrate working
# of iterweekdays() method
# importing calendar module
import calendar
# providing firstweekday = 0
obj = calendar.Calendar(firstweekday = 0)
for day in obj.iterweekdays():
print(day)
輸出:
0 1 2 3 4 5 6
代碼2:
# Python program to demonstrate working
# of iterweekdays() method
# importing calendar module
import calendar
# providing firstweekday = 2
obj = calendar.Calendar(firstweekday = 2)
for day in obj.iterweekdays():
print(day)
輸出:
2 3 4 5 6 0 1
相關用法
- Python calendar firstweekday()用法及代碼示例
- Python calendar isleap()用法及代碼示例
- Python calendar setfirstweekday()用法及代碼示例
- Python calendar itermonthdays()用法及代碼示例
- Python calendar itermonthdays2()用法及代碼示例
- Python calendar monthdatescalendar()用法及代碼示例
- Python calendar monthdays2calendar()用法及代碼示例
- Python calendar yeardayscalendar()用法及代碼示例
- Python calendar leapdays()用法及代碼示例
- Python calendar yeardays2calendar()用法及代碼示例
- Python calendar yeardatescalendar()用法及代碼示例
- Python calendar monthdayscalendar()用法及代碼示例
- Python calendar pryear()用法及代碼示例
- Python calendar prmonth()用法及代碼示例
- Python calendar formatyear()用法及代碼示例
注:本文由純淨天空篩選整理自Shivam_k大神的英文原創作品 Python calendar module | iterweekdays() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。