Notice
Recent Comments
Link
Tags
- 자바 파일 한줄씩 읽기
- mysql index 생성
- 우분투 시간변경
- 파이썬 반복문
- express install
- node js 버전확인
- npm버전확인
- index 생성
- 클라우드서버 생성
- 자바 한줄씩 읽기
- 라즈베리파이4
- c언어 파일 읽기
- ubuntu node js install
- 디지털오션 서버생성하기
- C언어
- 디지털오션 드로플릿
- raspi-config
- node js express install
- ubuntu node js
- c file read
- Node.js express install
- 우분투 시간설정
- Ubuntu timezone
- 우분투 node js 설치
- node 버전확인
- tzselect
- java 숫자를 문자로 변환하기
- 파이썬
- Python
- 디지털오션 클라우드서버 생성하기
Archives
- Today
- Total
호그래머
Python 날짜, 시간표현 (Date, Time) 23.01.24 본문
728x90
1. 파이썬 날짜, 시간 표현하기(Date, Time)
import time 필요
import time
logfilename = time.strftime("%Y%m%d-%H%M%S")
date_Y = time.strftime("%Y")
print("4자리 년:"+date_Y)
date_y = time.strftime("%y")
print("2자리 년:"+date_y)
date_m = time.strftime("%m")
print("2자리 원:"+date_m)
date_d = time.strftime("%d")
print("2자리 일:"+date_d)
date_Ymd = time.strftime("%Y%m%d")
print("8자리 년월일:"+date_Ymd)
date_H = time.strftime("%H")
print("2자리 시간(24시):"+date_H)
date_I = time.strftime("%I")
print("2자리 시간(12시):"+date_I)
date_p = time.strftime("%p")
print("AM/PM:"+date_p)
date_M = time.strftime("%M")
print("2자리 분:"+date_M)
date_S = time.strftime("%S")
print("2자리 초"+date_S)
date_HMS = time.strftime("%H%M%S")
print("6자리 시분초:"+date_HMS)
date_YmdHMS = time.strftime("%Y%m%d%H%M%S")
print("14자리 년월일시분초:"+date_YmdHMS)
date_YmdHMS_00 = time.strftime("%Y/%m/%d %H:%M:%S")
print("년/월/일 시:분:초 - "+date_YmdHMS_00)
끝
1. 파이썬으로 시간을 표현할 수 있다.
2. 알맞은 표현을 조합하여 원하는 날짜 시간을 표현할 수 있다.
728x90
'Python' 카테고리의 다른 글
Python if 사용하기 23.06.26 (0) | 2023.06.27 |
---|---|
Python text 파일 읽기 - 방법1 (파일읽기) 23.06.25 (0) | 2023.06.25 |
Python text 파일 쓰기 - 방법1 (파일쓰기) 23.06.25 (0) | 2023.06.25 |
Python 폴더 생성 (make directory) 23.01.24 (1) | 2023.01.24 |
Python 문자열 자르기(substring) 23.01.24 (0) | 2023.01.24 |
Comments