Python의 달력 함수 | 2개(monthrange(), prcal(), weekday()...)를 설정합니다.

  달력 기능 중 일부는 세트 1에서 설명됩니다. 1. 월간(년월) :- 이 함수는 다음을 반환합니다. 정수 두 개 첫째 주의 시작일 수(월요일은 0) 둘째 월의 일수 . 2. prcal(연도 w l c) :- 이 기능은 또한 특정 연도의 달력을 인쇄합니다. but there is no need of 'print' operation to execute this. Python
   # Python code to demonstrate the working of   # monthrange() and prcal()   # importing calendar module for calendar operations   import   calendar   # using monthrange() to print start week day and    # number of month   print   (  'The start week number and no. of days of month : '    end  =  ''  )   print   (  calendar  .  monthrange  (  2008     2  ))   # using prcal() to print calendar of 1997   print   (  'The calendar of 1997 is : '  )   calendar  .  prcal  (  1997     2    1    6  )   
Output:
The start week number and no. of days of month : (4 29) The calendar of 1997 is : 1997 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 5 1 2 1 2 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 27 28 29 30 31 24 25 26 27 28 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 6 1 2 3 4 1 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 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 6 1 2 3 1 2 3 4 5 6 7 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 28 29 30 31 25 26 27 28 29 30 31 29 30 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 5 1 2 1 2 3 4 5 6 7 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 27 28 29 30 31 24 25 26 27 28 29 30 29 30 31  

3. pmonth(년 월 w l) :- 이 기능은 또한 특정 연도의 월을 인쇄합니다. 하지만 이를 실행하기 위해 '인쇄' 작업이 필요하지 않습니다. 4. setfirstweekday(num) :- 이 함수는 일 시작 번호 of week. Python
   # Python code to demonstrate the working of   # prmonth() and setfirstweekday()   # importing calendar module for calendar operations   import   calendar   # using prmonth() to print calendar of 1997   print   (  'The 4th month of 1997 is : '  )   calendar  .  prmonth  (  1997     4     2     1  )   # using setfirstweekday() to set first week day number   calendar  .  setfirstweekday  (  4  )   print   (  '  r  '  )   # using firstweekday() to check the changed day   print   (  'The new week day number is : '    end  =  ''  )   print   (  calendar  .  firstweekday  ())   
Output:
The 4th month of 1997 is : April 1997 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 The new week day number is : 4  

5. 평일(년월일) :- 이 함수는 요일 번호 (0 is Monday) of the date specified in its arguments. Python
   # Python code to demonstrate the working of   # weekday()   # importing calendar module for calendar operations   import   calendar   # using weekday() to print day number of date   print   (  'The day number of 25 April 1997 is : '    end  =  ''  )   print   (  calendar  .  weekday  (  1997    4    25  ))   
Output:
The day number of 25 April 1997 is : 4