2016-08-04 Python Snippet : Date 字串轉日期 import timestartTime='2016-08-07 11:00'regularStartTime = time.strptime(startTime, "%Y-%m-%d %H:%M")print regularStartTime#>>> time.struct_time(tm_year=2016, tm_mon=8, tm_mday=7, tm_hour=11, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=220, tm_isdst=-1) 字串轉為指定格式的datetime import datetimestartTime='2016-08-07 11:00'regularStartTime = datetime.datetime.strptime(startTime, "%Y-%m-%d %H:%M")print regularStartTime#>>> 2016-08-07 11:00:00print regularStartTime.strftime("%Y-%m-%d")#>>> 2016-08-07 date 加法 datetime.datetime.now()start += datetime.timedelta(days=7) Newer 在Linux更改Java版本 Older 導入 Git 的初始化指令