반응형
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 | 31 |
Tags
- c#
- PANDAS
- numpy
- list
- PySpark
- Kotlin
- Presto
- Apache
- gas
- SQL
- 파이썬
- PostgreSQL
- django
- string
- Tkinter
- dataframe
- array
- Python
- Redshift
- Google Spreadsheet
- Google Excel
- GIT
- Github
- hive
- Java
- math
- matplotlib
- Excel
- google apps script
Archives
- Today
- Total
목록Python/Python datetime (11)
달나라 노트
Python datetime : year, month, day (년, 월, 일 추출하기)
import datetime today = datetime.date.today() y = today.year m = today.month d = today.day w = today.weekday() print(y) print(m) print(d) print(w) - Result 2020 3 8 6 datetime 모듈의 date class에 today method를 사용하거나 직접 년, 월, 일을 입력해주어 date 객체를 생성합니다. 이 생성한 date class의 year, month, day attribute를 이용하여 년, 월, 일을 추출할 수 있으며 weekday method를 이용하여 요일별 숫자(월 = 0, 화 = 1, ... 일 = 6)를 얻어낼 수 있습니다.
Python/Python datetime
2020. 12. 23. 02:39
Python datetime : fromtimestamp (Unix timestamp를 날짜로 변환하기)
import datetime d = datetime.date.fromtimestamp(1583644364) print(d) - Result 2020-03-08 date 객체 생성 시 년, 월, 일을 받지 않고 fromtimestamp method를 사용하여 Unix timestamp를 날짜로 변환하여 얻을 수 있습니다. Unix timestamp는 1970년 1월 1일(UTC)부터 몇 초가 흘렀는지를 나타내는 수치입니다.
Python/Python datetime
2020. 12. 23. 02:39