Skip to content

Instantly share code, notes, and snippets.

@seungwoonlee
Created April 19, 2019 08:27
Show Gist options
  • Save seungwoonlee/6c3f26b6379c5557313576544307c2be to your computer and use it in GitHub Desktop.
Save seungwoonlee/6c3f26b6379c5557313576544307c2be to your computer and use it in GitHub Desktop.
한글 날짜 문자열을 dateutil.parser.parse() 에서 사용하기 위해서 간단 정규식 활용
import re # 정규식(Regular Expression)
str = '2019-04-19 오후 1:50:39' # 2019-04-19 1:50:39 PM 로 바꾸고 싶다. dateutil.parser.parse()를 사용하기 위해서
list = re.split('오후 ', str) # '오후 '를 str에서 찾아서 둘로 쪼개어 각각을 list에 넣는다. 오후 다음에 Space가 있음에 유의
print(list)
newstr = list[0] + list[1] + ' PM'
print(newstr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment