fmt_1 = '%a %d %B %Y %H:%M:%S %z'
fmt_2 = '%a %d %b %Y %H:%M:%S %z'
t1="Sat 14 Sep 2126 00:36:44 +1400"
code1= dateime.datime.strptime(t1,fmt_1) #run time error
code2= dateime.datime.strptime(t1,fmt_2) #right code
为此,我遇到了fmt_1的运行时错误,并通过使用fmt_2进行了修复
%b和%B有什么区别?
From the documentation about Format Codes
%b
is for Month as locale’s abbreviated name. LikeJan, Feb, …, Dec
%B
is for Month as locale’s full name. LikeJanuary, February, …, December
In
Sat 14 Sep 2126 00:36:44 +1400
the monthSep
is inabbreviated
format so%b
fits, wher%B
doesn't