반응형
    
    
    
  
from datetime import datetime
format_data = "%Y-%m-%d %H:%M:%S.%f"
now_str = datetime.now().strftime(format_data)
print(now_str)
# 2022-08-22 19:11:38.565332
포멧 종류는 아래와 같습니다.
| format code | meaning | example | 
| %a | Abbreviated weekday name | Sun, Mon | 
| %A | Full weekday name | Sunday, Monday | 
| %w | Weekday as decimal number | 0…6 | 
| %d | Day of the month as a zero-padded decimal | 01, 02 | 
| %-d | day of the month as decimal number | 1, 2.. | 
| %b | Abbreviated month name | Jan, Feb | 
| %m | month as a zero padded decimal number | 01, 02 | 
| %-m | month as a decimal number | 1, 2 | 
| %B | Full month name | January, February | 
| %y | year without century as a zero padded decimal number | 99, 00 | 
| %-y | year without century as a decimal number | 0, 99 | 
| %Y | year with century as a decimal number | 2000, 1999 | 
| %H | hour(24 hour clock) as a zero padded decimal number | 01, 23 | 
| %-H | hour(24 hour clock) as a decimal number | 1, 23 | 
| %I | hour(12 hour clock) as a zero padded decimal number | 01, 12 | 
| %-I | hour(12 hour clock) as a decimal number | 1, 12 | 
| %p | locale’s AM or PM | AM, PM | 
| %M | Minute as a zero padded decimal number | 01, 59 | 
| %-M | Minute as a decimal number | 1, 59 | 
| %S | Second as a zero padded decimal number | 01, 59 | 
| %-S | Second as a decimal number | 1, 59 | 
| %f | microsecond as a decimal number, zero padded on the left side | 000000, 999999 | 
| %z | UTC offset in the form +HHMM or -HHMM | |
| %Z | Time zone name | |
| %j | day of the year as a zero padded decimal number | 001, 365 | 
| %-j | day of the year as a decimal number | 1, 365 | 
| %U | Week number of the year (Sunday being the first) | 0, 6 | 
| %W | Week number of the year | 00, 53 | 
| %c | locale’s appropriate date and time representation | Mon Sep 30 07:06:05 2013 | 
| %x | locale’s appropriate date representation | 11/30/98 | 
| %X | locale’s appropriate time representation | 10:03:43 | 
| %% | A literal ‘%’ character | % | 
728x90
    
    
  반응형
    
    
    
  'Python' 카테고리의 다른 글
| [Python] exception 메시지 자세히 출력하기 (Traceback) (0) | 2022.10.25 | 
|---|---|
| [Python] host(ip,url) port 로 연결 가능한지 확인 port 로 Ping 날려보기 (2) | 2022.09.28 | 
| [Python] 실행시간 체크하기. decorator 사용하기 (0) | 2022.08.13 | 
| [Python] PIL.Image 를 byte array 로 변환 (0) | 2022.06.20 | 
| [Python] tensor 를 이미지로 저장하기 (0) | 2022.06.20 | 
										
									
										
									
										
									
										
									
댓글