Skip to content

Instantly share code, notes, and snippets.

@seungwoonlee
Last active April 19, 2019 10:42
Show Gist options
  • Save seungwoonlee/2e2636bcb33fc08c0e3431cc81a0eb01 to your computer and use it in GitHub Desktop.
Save seungwoonlee/2e2636bcb33fc08c0e3431cc81a0eb01 to your computer and use it in GitHub Desktop.
한글이 포함된 날짜 문자열을 정규식만으로 변환
import re # 정규식(Regular Expression)
str = '2019-04-19 오후 1:50:39' # 2019-04-19 1:50:39 PM 로 바꾸고 싶다. dateutil.parser.parse()를 사용하기 위해서
newstr = re.sub(r"(\S+) 오후 (\S+)", r"\1 \2 PM", str) # 2019-04-19 1:50:39 PM
print(newstr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment