[Python]calendar.month()で月間カレンダーを列幅、行幅に指定するサンプル
環境
PyCharm 2021.3
Python 3.9.2
書式
calendar.month()で任意の年・月のカレンダーを文字列(str型)で取得できます。
引数wで列幅、引数lで行幅を指定します。
使用例
import calendar
print('列幅、行幅を指定して月間カレンダーを表示する')
print(calendar.month(2022, 5, w=3,l=2))
print('月間カレンダーのタイプ')
print(type(calendar.month(2022, 5)))
実行結果
列幅、行幅を指定して月間カレンダーを表示する
May 2022
Mon Tue Wed Thu Fri Sat Sun
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'>