Skip to content

Instantly share code, notes, and snippets.

@seungwoonlee
Created April 19, 2019 08:30
Show Gist options
  • Save seungwoonlee/e9a1f1e3a600a601cf406cd6774733ab to your computer and use it in GitHub Desktop.
Save seungwoonlee/e9a1f1e3a600a601cf406cd6774733ab to your computer and use it in GitHub Desktop.
날짜 문자열을 날짜 데이터형으로 변환
import dateutil.parser # pip install python-dateutil
str = '2019-04-19 1:50:39 PM' # 이런형태의 문자열을 날짜형으로 인식시켜야 한다
#str = '2019-04-19 오후 1:50:39' # 한글은 안되는거 같음
dt = dateutil.parser.parse(str) # 날짜로 추정되는 문자열을 datetime 데이터형으로 변환
print(type(dt)) # t 의 데이터형
print(dt)
print(dt.date())
print(dt.time())
print(dt.tzinfo) # 로컬시간을 보고 있음
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment