Python,将9元组UTC日期转换为MySQL日期时间格式

Neo*_*nja 11 python mysql sql datetime tuples

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

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

我有点难以理解如何将其转换为MySQL日期时间格式(Ymd H:M:S)?

var*_*tec 20

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')
Run Code Online (Sandbox Code Playgroud)