A built in command line tool in Python is the calendar command, added in version 2.5. Using this you can print out a full calendar of the current year.
$ python3 -m calendar
2026
January February March
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
1 2 3 4 1 1
5 6 7 8 9 10 11 2 3 4 5 6 7 8 2 3 4 5 6 7 8
12 13 14 15 16 17 18 9 10 11 12 13 14 15 9 10 11 12 13 14 15
19 20 21 22 23 24 25 16 17 18 19 20 21 22 16 17 18 19 20 21 22
26 27 28 29 30 31 23 24 25 26 27 28 23 24 25 26 27 28 29
30 31
-- rest of calendar cut off here --Or just a single month of a given year.
$ python3 -m calendar 2026 1
January 2026
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 31The calendar can be manipulated using different flags. For example, to set the first day of the week to be Wednesday and display 1 month per "line" of the calendar.
$ python3 -m calendar 2026 --months=1 --first-weekday=2
January
We Th Fr Sa Su Mo Tu
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
February
We Th Fr Sa Su Mo Tu
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
-- rest of calendar cut off here --You can also format the calendar in HTML by passing in the --type flag. The output is rather lengthy here, so I don't print it out.
python3 -m calendar --type=html 2026Note that HTML formatting does not support the year-month option, but you may only get this cryptic message that states "error: incorrect number of arguments".
For a full range of the arguments use the -h or --help flags.
Read more about the calendar command in the Python documentation for the calendar library.
Add new comment