Thursday, 14 July 2016

Python: Calendar: Print year calendar

calendar.prcal(year, w=0, l=0, c=6, m=3)
Above method is used to get calendar for entire year. It return m-column calendar year. ‘w’ specifies date column width, ‘l’ specifies lines per week, ‘c’ specifies number spaces between month columns.
>>> import calendar
>>> calendar.prcal(2015)
                                  2015

      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

       April                      May                       June
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  5                   1  2  3       1  2  3  4  5  6  7
 6  7  8  9 10 11 12       4  5  6  7  8  9 10       8  9 10 11 12 13 14
13 14 15 16 17 18 19      11 12 13 14 15 16 17      15 16 17 18 19 20 21
20 21 22 23 24 25 26      18 19 20 21 22 23 24      22 23 24 25 26 27 28
27 28 29 30               25 26 27 28 29 30 31      29 30

        July                     August                  September
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  5                      1  2          1  2  3  4  5  6
 6  7  8  9 10 11 12       3  4  5  6  7  8  9       7  8  9 10 11 12 13
13 14 15 16 17 18 19      10 11 12 13 14 15 16      14 15 16 17 18 19 20
20 21 22 23 24 25 26      17 18 19 20 21 22 23      21 22 23 24 25 26 27
27 28 29 30 31            24 25 26 27 28 29 30      28 29 30
                          31

      October                   November                  December
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  2  3  4  5  6
 5  6  7  8  9 10 11       2  3  4  5  6  7  8       7  8  9 10 11 12 13
12 13 14 15 16 17 18       9 10 11 12 13 14 15      14 15 16 17 18 19 20
19 20 21 22 23 24 25      16 17 18 19 20 21 22      21 22 23 24 25 26 27
26 27 28 29 30 31         23 24 25 26 27 28 29      28 29 30 31
                          30

>>> 
>>> calendar.prcal(2015,m=5)
                                                            2015

      January                   February                   March                     April                      May
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      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             1  2  3  4  5                   1  2  3
 5  6  7  8  9 10 11       2  3  4  5  6  7  8       2  3  4  5  6  7  8       6  7  8  9 10 11 12       4  5  6  7  8  9 10
12 13 14 15 16 17 18       9 10 11 12 13 14 15       9 10 11 12 13 14 15      13 14 15 16 17 18 19      11 12 13 14 15 16 17
19 20 21 22 23 24 25      16 17 18 19 20 21 22      16 17 18 19 20 21 22      20 21 22 23 24 25 26      18 19 20 21 22 23 24
26 27 28 29 30 31         23 24 25 26 27 28         23 24 25 26 27 28 29      27 28 29 30               25 26 27 28 29 30 31
                                                    30 31

        June                      July                     August                  September                  October
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      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  5  6  7             1  2  3  4  5                      1  2          1  2  3  4  5  6                1  2  3  4
 8  9 10 11 12 13 14       6  7  8  9 10 11 12       3  4  5  6  7  8  9       7  8  9 10 11 12 13       5  6  7  8  9 10 11
15 16 17 18 19 20 21      13 14 15 16 17 18 19      10 11 12 13 14 15 16      14 15 16 17 18 19 20      12 13 14 15 16 17 18
22 23 24 25 26 27 28      20 21 22 23 24 25 26      17 18 19 20 21 22 23      21 22 23 24 25 26 27      19 20 21 22 23 24 25
29 30                     27 28 29 30 31            24 25 26 27 28 29 30      28 29 30                  26 27 28 29 30 31
                                                    31

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


Previous                                                 Next                                                 Home

No comments:

Post a Comment