라벨이 datetime인 게시물 표시

파이썬[Python]: datetime - dst 메서드

datetime 모듈 - timezone 클래스 - dst 메서드(method) /// 설명 일광 절약 시간제(Daylight saving time, DST)와 관련 있지만, 항상 None을 반환합니다. ※ 형식 timezone.dst(dt) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 import  datetime   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   test_tzname  =  test_timezone.dst( None ) print (test_tzname)   # None   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - tzname 메서드

datetime 모듈 - timezone 클래스 - tzname 메서드(method) /// 설명 timezone 이 생성되어질 경우 적용되어진 name의 값입니다. name 인자가 주어지지 않았을 경우, utcoffset() 가 반환하는 값과 같습니다. ※ 형식 timezone.tzname(dt) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import  datetime   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   test_tzname  =  test_timezone.tzname( None ) print (test_tzname)   # KST   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 )) print (test_timezone)   # UTC+09:00   test_tzname  =  test_timezone.tzname( None ) print (test_tzname)   # UTC+09:00   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - utcoffset 메서드

datetime 모듈 - timezone 클래스 - utcoffset 메서드(method) /// 설명 timezone 이 생성되어질 경우 적용되어진 offset의 값입니다. 인자 dt는 무시되어집니다. ※ 형식 timezone.utcoffset(dt) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 import  datetime   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   test_utcoffset  =  test_timezone.utcoffset( None ) print (test_utcoffset)   # 9:00:00   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - timezone 클래스

datetime 모듈 - timezone 클래스(class) /// 설명 tzinfo의 서브클래스로서 각 인스턴스는 timezone을 표현합니다.(timezone은 UTC 시간으로부터 고정된 offset을 갖습니다.) 인자 name은 timezone의 특정 이름을 칭합니다. ※ 형식 class datetime.timezone(offset, name=None) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import  datetime   # UTC test_timezone  =  datetime.timezone(datetime.timedelta(hours = 0 )) print (test_timezone)   # UTC   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 )) print (test_timezone)   # UTC+09:00   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - __format__ 메서드

datetime 모듈 - date 클래스 - __format__ 메서드(method) /// 설명 형식(format)에 맞는 날짜를 문자열로 반환합니다. strftime() 메서드와 동일합니다. 형식은 다음을 참고하십시오. strftime() and strptime() Behavior ※ 형식 date.__format__(format) /// 예제 1 2 3 4 5 6 import  datetime   # Form: week month days hours:minutes:seconds years test_str  =  datetime.date( 2021 ,  11 ,  23 ).__format__( '%Y-%m-%d %H:%M:%S' ) print (test_str)   # 2021-11-23 00:00:00   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - strftime 메서드

datetime 모듈 - date 클래스 - strftime 메서드(method) /// 설명 형식(format)에 맞는 날짜를 문자열로 반환합니다. 형식은 다음을 참고하십시오. strftime() and strptime() Behavior ※ 형식 date.strftime(format) /// 예제 1 2 3 4 5 6 import  datetime   # Form: week month days hours:minutes:seconds years test_str  =  datetime.date( 2021 ,  11 ,  23 ).strftime( '%Y-%m-%d %H:%M:%S' ) print (test_str)   # 2021-11-23 00:00:00   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - ctime 메서드

datetime 모듈 - date 클래스 - ctime 메서드(method) /// 설명 날짜를 문자열로 반환합니다. (문자열 형식: 요일 월 일 시:분:초 년) ※ 형식 date.ctime() /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  time import  datetime   # Form: week month days hours:minutes:seconds years test_str  =  datetime.date( 2021 ,  11 ,  23 ).ctime() print (test_str)   # Tue Nov 23 00:00:00 2021   # related to this method ------------------------------ print (time.ctime(time.mktime(datetime.date( 2021 ,  11 ,  23 ).timetuple()))) # Tue Nov 23 00:00:00 2021   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - __str__ 메서드

datetime 모듈 - date 클래스 - __str__ 메서드(method) /// 설명 ISO 8601 형식(YYYY-MM-DD)에 맞는 날짜를 문자열로 반환합니다. isoformat() 메서드와 동일합니다. ※ 형식 date.__str__() /// 예제 1 2 3 4 5 6 7 8 9 10 import  time import  datetime   # iso calendar test_today  =  datetime.date( 2021 ,  11 ,  23 ).isocalendar() print (test_today)   # datetime.IsoCalendarDate(year=2021, week=47, weekday=2)   test_str  =  datetime.date( 2021 ,  11 ,  23 ).__str__() print (test_str)   # 2021-11-23   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - isoformat 메서드

datetime 모듈 - date 클래스 - isoformat 메서드(method) /// 설명 ISO 8601 형식(YYYY-MM-DD)에 맞는 날짜를 문자열로 반환합니다. ※ 형식 date.isoformat() /// 예제 1 2 3 4 5 6 7 8 9 10 import  time import  datetime   # iso calendar test_today  =  datetime.date( 2021 ,  11 ,  23 ).isocalendar() print (test_today)   # datetime.IsoCalendarDate(year=2021, week=47, weekday=2)   test_str  =  datetime.date( 2021 ,  11 ,  23 ).isoformat() print (test_str)   # 2021-11-23   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - isoweekday 메서드

datetime 모듈 - date 클래스 - isoweekday 메서드(method) /// 설명 일주일의 각 요일에 맞는 정수를 반환합니다.(ISO 달력)(월=1, 화=2, 수=3, 목=4, 금=5, 토=6, 일=7) ※ 형식 date.isoweekday() /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  time import  datetime   # iso calendar test_today  =  datetime.date( 2021 ,  11 ,  23 ).isocalendar() print (test_today)   # datetime.IsoCalendarDate(year=2021, week=47, weekday=2)   # Mon=1,  Tue=2,  Wen=3, Thu=4, Fri=5,  Sat=6,  Sun=7 test_isoweekday  =  datetime.date( 2021 ,  11 ,  23 ).isoweekday() print (test_isoweekday)   # 2   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - weekday 메서드

datetime 모듈 - date 클래스 - weekday 메서드(method) /// 설명 일주일의 각 요일에 맞는 정수를 반환합니다.(월=0, 화=1, 수=2, 목=3, 금=4, 토=5, 일=6) ※ 형식 date.weekday() /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 import  time import  datetime   # iso calendar test_today  =  datetime.date( 2021 ,  11 ,  23 ).isocalendar() print (test_today)   # datetime.IsoCalendarDate(year=2021, week=47, weekday=2)   # not iso weekday(isoweekday - 1) # Mon=0,  Tue=1,  Wen=2, Thu=3, Fri=4,  Sat=5,  Sun=6 test_weekday  =  datetime.date( 2021 ,  11 ,  23 ).weekday() print (test_weekday)   # 1   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - toordinal 메서드

datetime 모듈 - date 클래스 - toordinal 메서드(method) /// 설명 January 1 of year 1 부터 객체의 값까지의 ordinal을 반환합니다.(그레고리력) ※ 형식 date.toordinal() /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import  time import  datetime   test_today  =  datetime.date( 2021 ,  11 ,  23 ).isocalendar() print (test_today)   # datetime.IsoCalendarDate(year=2021, week=47, weekday=2)   # year, week, weekday from test_today test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar)   # 2021-11-23   # from January 1 of year 1 test_toordinal  =  test_calendar.toordinal() print (test_toordinal)   # 738117   # related to this method ------------------------------ test_ord  =  datetime.date.fromordinal(test_toordinal) print (test_ord)   # 2021-11-23   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - timetuple 메서드

datetime 모듈 - date 클래스 - timetuple 메서드(method) /// 설명 time.localtime() 에서 반환되는 것과 같은 구조를 반환합니다. ※ 형식 date.timetuple() /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import  time import  datetime   test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar)   # 2021-11-23   test_timetuple  =  test_calendar.timetuple() print (test_timetuple)   # 2022-11-23   # related to this method ------------------------------ test_time  =  time.time() # epoch: the time starts + 9 (Korea Standard Time, KST = UTC + 9) print (time.localtime(test_time)) # time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - replace 메서드

datetime 모듈 - date 클래스 - replace 메서드(method) /// 설명 date 객체 중 각 인자에 맞는 값을 치환합니다. ※ 형식 date.replace(year=self.year, month=self.month, day=self.day) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import  datetime   test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar)   # 2021-11-23   test_year_replace  =  test_calendar.replace(year = 2022 ) print (test_year_replace)   # 2022-11-23   test_year_replace  =  test_calendar.replace(month = 5 ) print (test_year_replace)   # 2021-5-23   test_year_replace  =  test_calendar.replace(day = 26 ) print (test_year_replace)   # 2021-11-26   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - day 변수

datetime 모듈 - date 클래스 - day 변수(variable) /// 설명 date 객체 중 day 를 반환합니다. ※ 형식 date.day /// 예제 1 2 3 4 5 6 7 import  datetime   print (datetime.date.today())   # 2021-11-23   test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar.day)   # 23   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - month 변수

datetime 모듈 - date 클래스 - month 변수(variable) /// 설명 date 객체 중 month 를 반환합니다. ※ 형식 date.month /// 예제 1 2 3 4 5 6 import  datetime   print (datetime.date.today())   # 2021-11-23   test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar.month)   # 11 cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - year 변수

datetime 모듈 - date 클래스 - year 변수(variable) /// 설명 date 객체 중 year 를 반환합니다. ※ 형식 date.year reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 import  datetime   print (datetime.date.today())   # 2021-11-23   test_calendar  =  datetime.date.fromisocalendar( 2021 ,  47 ,  2 ) print (test_calendar.year)   # 2021   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - resolution 상수

datetime 모듈 - date 클래스 - resolution 상수(constant) /// 설명 객체를 비교할 수 있는 가장 작은 값입니다.(1 day) ※ 형식 date.resolution /// 예제 1 2 3 4 5 6 7 import  datetime   test_resolution  =  datetime.date.resolution print (test_resolution)   # 1 day, 0:00:00   # related to this method ------------------------------ print (datetime.timedelta(days = 1 ))   # 1 day, 0:00:00 cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - max 상수 (date)

datetime 모듈 - date 클래스 - max 상수(constant) /// 설명 달력이 표현할 수 있는 가장 늦은 시기입니다. ※ 형식 date.max /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_max  =  datetime.date.max print (test_max)   # 9999-12-31   # related to this method ------------------------------ print (datetime.date(datetime.MAXYEAR,  12 ,  31 ))   # 9999-12-31   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - min 상수

datetime 모듈 - date 클래스 - min 상수(constant) /// 설명 달력이 표현할 수 있는 가장 이른 시기입니다. ※ 형식 date.min reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_min  =  datetime.date.min print (test_min)   # 0001-01-01   # related to this method ------------------------------ print (datetime.date(datetime.MINYEAR,  1 ,  1 ))   # 0001-01-01   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –