python
Python의 Calendar 모듈에는 날짜, 월, 연도를 기반으로 다양한 작업을 계산할 수 있는 달력 클래스가 있습니다. 게다가 Python의 TextCalendar 및 HTMLCalendar 클래스를 사용하면 달력을 편집하고 요구 사항에 따라 사용할 수 있습니다.
Python Calendar로 무엇을 할 수 있는지 봅시다.
1단계) 코드를 실행합니다.
값을 일요일에서 목요일로 빠르게 변경하고 출력을 확인합시다.
2단계) 캘린더를 HTML 형식으로 인쇄할 수도 있습니다. 이 기능은 캘린더의 모양과 느낌을 변경하려는 개발자에게 유용합니다.
3단계) c.itermonthday(2025,4)를 사용하여 한 달의 날짜를 반복하면 해당 달의 총 날짜 수를 가져옵니다.
4단계) 월 또는 주중 등과 같은 로컬 시스템에서 데이터를 가져올 수 있습니다.
5단계) 1년 전체의 특정 날짜 목록을 가져올 수 있습니다. 예를 들어, 매주 첫 번째 월요일에 감사일이 있습니다. 매월 첫 번째 월요일의 날짜를 알고 싶습니다. 이 코드를 사용할 수 있습니다.
전체 코드는 다음과 같습니다.
Python 2 예제
import calendar # Create a plain text calendar c = calendar.TextCalendar(calendar.THURSDAY) str = c.formatmonth(2025, 1, 0, 0) print str # Create an HTML formatted calendar hc = calendar.HTMLCalendar(calendar.THURSDAY) str = hc.formatmonth(2025, 1) print str # loop over the days of a month # zeroes indicate that the day of the week is in a next month or overlapping month for i in c.itermonthdays(2025, 4): print i # The calendar can give info based on local such a names of days and months (full and abbreviated forms) for name in calendar.month_name: print name for day in calendar.day_name: print day # calculate days based on a rule: For instance an audit day on the second Monday of every month # Figure out what days that would be for each month, we can use the script as shown here for month in range(1, 13): # It retrieves a list of weeks that represent the month mycal = calendar.monthcalendar(2025, month) # The first MONDAY has to be within the first two weeks week1 = mycal[0] week2 = mycal[1] if week1[calendar.MONDAY] != 0: auditday = week1[calendar.MONDAY] else: # if the first MONDAY isn't in the first week, it must be in the second week auditday = week2[calendar.MONDAY] print "%10s %2d" % (calendar.month_name[month], auditday)
Python 3 예제
import calendar # Create a plain text calendar c = calendar.TextCalendar(calendar.THURSDAY) str = c.formatmonth(2025, 1, 0, 0) print(str) # Create an HTML formatted calendar hc = calendar.HTMLCalendar(calendar.THURSDAY) str = hc.formatmonth(2025, 1) print(str) # loop over the days of a month # zeroes indicate that the day of the week is in a next month or overlapping month for i in c.itermonthdays(2025, 4): print(i) # The calendar can give info based on local such a names of days and months (full and abbreviated forms) for name in calendar.month_name: print(name) for day in calendar.day_name: print(day) # calculate days based on a rule: For instance an audit day on the second Monday of every month # Figure out what days that would be for each month, we can use the script as shown here for month in range(1, 13): # It retrieves a list of weeks that represent the month mycal = calendar.monthcalendar(2025, month) # The first MONDAY has to be within the first two weeks week1 = mycal[0] week2 = mycal[1] if week1[calendar.MONDAY] != 0: auditday = week1[calendar.MONDAY] else: # if the first MONDAY isn't in the first week, it must be in the second week auditday = week2[calendar.MONDAY] print("%10s %2d" % (calendar.month_name[month], auditday))
python
Pillow Python Imaging Library는 이미지 처리에 이상적입니다. 일반적으로 보관 및 일괄 처리 응용 프로그램에 사용됩니다. 물론, 생각할 수 있는 다른 용도로 자유롭게 사용할 수 있습니다. 라이브러리를 사용하여 다음을 수행할 수 있습니다. 썸네일 만들기 파일 형식 간 변환, 이미지 인쇄 Fet 히스토그램(자동 대비 향상에 이상적) 이미지 회전 흐림 효과와 같은 필터 적용 목차 이미지 처리 패키지 설치 이미지 처리 중 이미지 표시 추가 정보 이미지 처리 패키지 설치 Pillow를 설치하려면 원래 Pyth
Python 생태계에서 생각할 수 있는 거의 모든 것을 위한 패키지가 있으며, 모두 간단한 pip 명령으로 설치할 수 있습니다. 따라서 Python에도 이모티콘을 사용할 수 있는 패키지가 있다는 사실에 놀라지 마세요. 다음을 사용하여 이모티콘 패키지를 설치할 수 있습니다. $ pip3 install emoji 이 패키지를 사용하면 유니코드 이모티콘을 문자열 버전으로 또는 그 반대로 변환할 수 있습니다. import emoji result = emoji.emojize(Python is :thumbs_up:) print(result