본문 바로가기

Python

python | 코드내에서 현재 시간 출력하기

python 파이선 

현재시간 출력하기 

 

 

 

1. time 모듈 불러오기

import time - 페이지 맨 위에 작성

 

 

 

2. 해당 모듈을 사용하여 날짜, 시간 사용 

time.strftime('%H%M%S')  - 시분초 불러오기 

출력값 | 213641

 

time.strftime('%Y-%m-%d %H:%M:%S') - 년-월-일 시:분:초 불러오기

출력값 | 2021-03-09 21:37:23

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import time 
 
time.strftime('%H%M%S'# 213641
time.strftime('%D'#03/09/21
time.strftime('%d'#09
 
time.strftime('%Y-%m-%d %H:%M:%S'#2021-03-09 21:37:23
time.strftime('%y-%m-%d %H:%M:%S'#21-03-09 21:37:23
 
 
time.strftime('%a'#Tue
time.strftime('%A'#Tuesday
time.strftime('%D'#Tuesday
 
 
 

 

반응형