itermonthdays2() 在 Python 中是什麼?


itermonthdays2()。它類似於 itermonthdates(),返回的天數是元組(即)它包含一個天數和一個星期幾。此方法用於獲取一年中某個月份的迭代器。

示例

import calendar
i= calendar.Calendar()
for days in i.itermonthdays2(2019, 5):
print(days)

輸出

(0, 0)
(0, 1)
(0, 2)
(0, 3)
(0, 4)
(0, 5)
(1, 6)
(2, 0)
(3, 1)
(4, 2)
(5, 3)
(6, 4)
(7, 5)
(8, 6)
(9, 0)
(10, 1)
(11, 2)
(12, 3)
(13, 4)
(14, 5)
(15, 6)
(16, 0)
(17, 1)
(18, 2)
(19, 3)
(20, 4)
(21, 5)
(22, 6)
(23, 0)
(24, 1)
(25, 2)
(26, 3)
(27, 4)
(28, 5)
(29, 6)
(30, 0)
(31, 1)
(0, 2)
(0, 3)
(0, 4)
(0, 5)
(0, 6)

更新於:2019 年 7 月 30 日

118 瀏覽量

開啟你的職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.