from datetime import *
t_str = '2015-04-07 19:11:21'
d = datetime.strptime(t_str, '%Y-%m-%d %H:%M:%S')
print d
# 带微秒的时间
d2 = datetime.strptime(t_str2, '%Y-%m-%d %H:%M:%S.%f')
t_str2 = '2015-04-07 19:32:21.233'
print d2
%Y 年
%m 月
%d 日
%H 时
%M 分
%S 秒
%f 毫秒