Python Calendar.itermonthdays4() 方法
Calendar.itermonthdays4() 方法是內置的方法Calendar
類calendar
Python 中的模塊。它使用此類的實例並返回給定年份中給定月份的迭代器。該月由整周組成,即,即使該值在該月之外,每周也有整整 7 個值。一周中的一個條目由一個元組給出,該元組由年、月、月中的某一天和工作日編號組成,即該日的工作日。
該方法從 3.7 版開始可用
模塊:
import calendar
類:
from calendar import Calendar
用法:
itermonthdays4(year, month)
參數:
year
:它是一個必需參數,它指定日曆的年份。month
:它是一個必需參數,它指定日曆的月份。
返回值:
這個方法的返回類型是<class 'generator'>
,它返回一個月份的迭代器,其中每個元組告訴您該月的完整日期和日期。
例:
# Python program to illustrate the
# use of itermonthdays4() method
# import class
import calendar
# Creating Calendar Instance
cal = calendar.Calendar()
year = 2017
month = 11
for i in cal.itermonthdays4(year, month):
print(i)
# tuple value is:year,month,day, weekday number
# Note:iterator always start from firstweekday number
print()
print()
# set the firstweekday to 3
cal = calendar.Calendar(firstweekday = 3)
year = 1994
month = 7
for i in cal.itermonthdays4(year, month):
print(i)
print()
print()
輸出
(2017, 10, 30, 0) (2017, 10, 31, 1) (2017, 11, 1, 2) (2017, 11, 2, 3) (2017, 11, 3, 4) (2017, 11, 4, 5) (2017, 11, 5, 6) (2017, 11, 6, 0) (2017, 11, 7, 1) (2017, 11, 8, 2) (2017, 11, 9, 3) (2017, 11, 10, 4) (2017, 11, 11, 5) (2017, 11, 12, 6) (2017, 11, 13, 0) (2017, 11, 14, 1) (2017, 11, 15, 2) (2017, 11, 16, 3) (2017, 11, 17, 4) (2017, 11, 18, 5) (2017, 11, 19, 6) (2017, 11, 20, 0) (2017, 11, 21, 1) (2017, 11, 22, 2) (2017, 11, 23, 3) (2017, 11, 24, 4) (2017, 11, 25, 5) (2017, 11, 26, 6) (2017, 11, 27, 0) (2017, 11, 28, 1) (2017, 11, 29, 2) (2017, 11, 30, 3) (2017, 12, 1, 4) (2017, 12, 2, 5) (2017, 12, 3, 6) (1994, 6, 30, 3) (1994, 7, 1, 4) (1994, 7, 2, 5) (1994, 7, 3, 6) (1994, 7, 4, 0) (1994, 7, 5, 1) (1994, 7, 6, 2) (1994, 7, 7, 3) (1994, 7, 8, 4) (1994, 7, 9, 5) (1994, 7, 10, 6) (1994, 7, 11, 0) (1994, 7, 12, 1) (1994, 7, 13, 2) (1994, 7, 14, 3) (1994, 7, 15, 4) (1994, 7, 16, 5) (1994, 7, 17, 6) (1994, 7, 18, 0) (1994, 7, 19, 1) (1994, 7, 20, 2) (1994, 7, 21, 3) (1994, 7, 22, 4) (1994, 7, 23, 5) (1994, 7, 24, 6) (1994, 7, 25, 0) (1994, 7, 26, 1) (1994, 7, 27, 2) (1994, 7, 28, 3) (1994, 7, 29, 4) (1994, 7, 30, 5) (1994, 7, 31, 6) (1994, 8, 1, 0) (1994, 8, 2, 1) (1994, 8, 3, 2)
相關用法
- Python Calendar itermonthdays2()用法及代碼示例
- Python Calendar itermonthdays3()用法及代碼示例
- Python Calendar itermonthdays()用法及代碼示例
- Python Calendar itermonthdates()用法及代碼示例
- Python Calendar iterweekdays()用法及代碼示例
- 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 | itermonthdays4() Method with Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。