prmonth() 方法在 python 中是什麼意思?


Python 有一個內建模組名為日曆,其中包含用於支援各種日曆操作的類和函式,預設情況下日曆模組遵循公曆。 

prmonth() 方法是 TextCalendar 例項的方法之一。用於列印由 formatmonth() 返回的一個月的日曆。

 語法: prmonth(year, month, width=0, lines=0) 

傳遞給此函式的引數分別是年 (yyyy)、月 (m)、日期列寬 (w) 和每星期行數 (l)。例如,讓我們使用此函式來列印 2019 年 5 月的日曆

示例

#importing calendar
import calendar
#let say 'i' is an variable
i = calendar.TextCalendar()
#printing the prmonth
print(i.prmonth(2019, 5))

輸出

May 2019
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
None

更新於: 2019-07-30

146 次檢視

開始你的職業生涯

完成課程獲得證書

開始
廣告
© . All rights reserved.