반응형
from datetime import timedelta
# 현재 날짜
today = datetime.today()
# 현재 년도, 월, 일, 시간
current_year = datetime.today().year
current_month = datetime.today().month
current_day = datetime.today().day
current_hour = datetime.today().hour
# 어제, 내일
yesterday = datetime.today() - timedelta(1)
tomorrow = datetime.today() + timedelta(1)
# 날짜 표기 형식 변경 -> YYYY.mm.dd HH:MM:SS
today = datetime.today().strftime(f'%Y.%m.%d %H:%M:%S')
반응형
'프로그래밍 > python' 카테고리의 다른 글
dataframe contains and operation 여러 조건을 만족하는 데이터 필터링 (0) | 2022.10.05 |
---|---|
문자열에서 숫자만 가져오는 여러 방법 (0) | 2022.09.29 |
pandas.Series.str.match 특정 단어와 완전 일치하는 데이터 필터링 (0) | 2022.09.27 |
브라우저가 멈출 정도의 로딩에 빠졌을 때 파이썬이 기다려 줄 수 있는 최대 시간 설정 (selenium의 time out exception 방지) (0) | 2022.09.23 |
Decompyle++ 윈도우 exe 파일 (14) | 2022.09.20 |