Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- pytorch
- C#
- C++
- VS Code
- label
- 핑거스타일
- ubuntu
- JSON
- 채보
- YOLO
- windows forms
- pandas
- nvidia-smi
- error
- paramiko
- 기타 연주
- 프로그래머스
- mysql
- 오류
- pip
- Python
- C
- Selenium
- 컨테이너
- SSH
- Docker
- Numpy
- OpenCV
- Visual Studio
- Linux
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python 날짜 문자열 변환 본문
import datetime
import time
now = datetime.datetime.now()
print(now) # 2022-08-25 09:11:41.090583
# yyyy-mm-dd 형식
formatted_date = now.strftime("%Y-%m-%d")
print(formatted_date) # 2022-08-25
print(type(formatted_date)) # <class 'str'>
print(type(now)) # <class 'datetime.datetime'>
strftime() 반환 결과는 string이다. strftime() 포맷 코드는 다음 문서를 참조
datetime — 기본 날짜와 시간 형 — Python 3.10.6 문서
datetime — 기본 날짜와 시간 형 소스 코드: Lib/datetime.py datetime 모듈은 날짜와 시간을 조작하는 클래스를 제공합니다. 날짜와 시간 산술이 지원되지만, 구현의 초점은 출력 포매팅과 조작을 위한
docs.python.org
'Python' 카테고리의 다른 글
Python 경로 확장자, 파일 이름 분리 (0) | 2022.09.17 |
---|---|
Python 특정 코드 실행 시간 시간:분:초 출력 (0) | 2022.09.11 |
Python RLock 자원 동시 접근 관리 (0) | 2022.07.22 |
Python Error argument after * must be an iterable, not Queue (0) | 2022.06.10 |
Python configparser key 대소문자 구분 (0) | 2022.05.21 |
Comments