Last active
October 7, 2023 22:59
-
-
Save FinanceData/46c463c22c4f9646c52b0d2ca17f82c8 to your computer and use it in GitHub Desktop.
Chapter_04_Date_and_Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"# Chapter 04 Date and Time\n", | |
"<img align=\"left\" src=\"https://i.imgur.com/lnc0qMV.png\" />" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"# 01 데이트타임 라이브러리(datetime Library)\n", | |
"\n", | |
"brian = \"Always look on the bright side of life!\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"2017-01-27 10:34:01.770067\n" | |
] | |
} | |
], | |
"source": [ | |
"# 02 현재 시간과 날짜 가져오기\n", | |
"from datetime import datetime\n", | |
"\n", | |
"now = datetime.now()\n", | |
"print (now)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"2017\n", | |
"1\n", | |
"27\n" | |
] | |
} | |
], | |
"source": [ | |
"# 03 정보 추출하기\n", | |
"\n", | |
"now = datetime.now()\n", | |
"print (now.year)\n", | |
"print (now.month)\n", | |
"print (now.day)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1/27/2017\n" | |
] | |
} | |
], | |
"source": [ | |
"# 04 날짜 정보 다듬기\n", | |
"\n", | |
"now = datetime.now()\n", | |
"print (str(now.month) + \"/\" + str(now.day) + \"/\" + str(now.year))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"10:34:1\n" | |
] | |
} | |
], | |
"source": [ | |
"# 05 시간 정보 다듬기\n", | |
"\n", | |
"now = datetime.now()\n", | |
"print (str(now.hour) + \":\" + str(now.minute) + \":\" + str(now.second))\n", | |
"#print (str(now.month) + \"/\" + str(now.day) + \"/\" + str(now.year))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1/27/2017 10:34:1\n" | |
] | |
} | |
], | |
"source": [ | |
"# 06 마무리\n", | |
"\n", | |
"now = datetime.now()\n", | |
"print (str(now.month) + \"/\" + str(now.day) + \"/\" + str(now.year), str(now.hour) + \":\" + str(now.minute) + \":\" + str(now.second))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"datetime.datetime(2017, 1, 27, 10, 34, 1, 832164)" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"now" | |
] | |
} | |
], | |
"metadata": { | |
"celltoolbar": "Slideshow", | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment