Python datetime 相關的使用方法
這會是一篇持續更新的文章,會把 datetime 相關的學習記錄下來。
from datetime import datetime, date, timedelta
date.today()
datetime.today()
datetime.now().strftime("%Y-%m-%d %H:%M:%S")
datetime.now().date()
datetime.today() - timedelta(days=1)
datetime.combine(date.today(), datetime.strptime(str_some_time, '%H:%M').time())
if (abs(datetime.today() - some_time) <= timedelta(minutes=10)):
print ("less than 10 minutes")
from datetime import datetime, date, timedelta
date.today()
datetime.today()
datetime.now().strftime("%Y-%m-%d %H:%M:%S")
datetime.now().date()
datetime.today() - timedelta(days=1)
datetime.combine(date.today(), datetime.strptime(str_some_time, '%H:%M').time())
if (abs(datetime.today() - some_time) <= timedelta(minutes=10)):
print ("less than 10 minutes")
留言
張貼留言