「Python」calendar.month()でカレンダーを取得する
環境
PyCharm 2021.3
Python 3.9.2
書式
calendar.month()で任意の年・月のカレンダーを文字列(str型)で取得できます。
使用例
import calendar
print('月間カレンダーを表示する')
print(calendar.month(2022, 5))
print('月間カレンダーのタイプ')
print(type(calendar.month(2022, 5)))
実行結果
月間カレンダーを表示する
May 2022
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
月間カレンダーのタイプ
<class 'str'>