This file contains hidden or 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
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()) |
This file contains hidden or 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
import maya # pip install maya ์ ์ค์น๊ฐ ์๋๋ ๋ฏ, ๋ ๋๊น์ง ๋ฐ๋ณต | |
str = '2019-04-19 1:50:39 PM' | |
dt = maya.parse(str).datetime() | |
print(dt) | |
print(dt.date()) | |
print(dt.time()) | |
print(dt.tzinfo) # ๊ธฐ๋ณธ์ ์ผ๋ก UTC๋ก ์ค์ |
This file contains hidden or 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
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) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
### Configuration ################################################ | |
CLIEN_USERID = 'XXXXXXXX' | |
CLIEN_PASSWD = 'XXXXXXXX' | |
TELEGRAM_TOKEN = '000000000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
TELEGRAM_CHAT_ID = '000000000' | |
### End of Configuration ######################################### | |
import argparse |
OlderNewer