12

我正在使用此处指定的格式解析 RSS 提要:http ://www.feedparser.org/docs/date-parsing.html

日期元组 (2009, 3, 23, 13, 6, 34, 0, 82, 0)

我对如何将其转换为 MySQL 日期时间格式 (Ymd H:M:S) 感到有些困惑?

4

1 回答 1

21
tup = (2009, 3, 23, 13, 6, 34, 0, 82, 0)
import datetime 
d = datetime.datetime(*(tup[0:6]))
#two equivalent ways to format it:
dStr = d.isoformat(' ')
#or
dStr = d.strftime('%Y-%m-%d %H:%M:%S')
于 2009-03-26T17:14:59.207 回答