题目受版权保护,不可转载。
input
Sun, 06 Nov 1994 08:49:37 GMT
Sunday, 06-Nov-94 08:49:37 GMT
Sun Nov 6 08:49:37 1994
output
1994-11-06 08:49:37
1994-11-06 08:49:37
1994-11-06 08:49:37
My Code
import sys
import datetime
def parse_http_datetime(s):
if '-'in s:
return datetime.datetime.strptime(s, "%A, %d-%b-%y %H:%M:%S %Z")
elif s[-1] in ['T']:
return datetime.datetime.strptime(s, "%a, %d %b %Y %H:%M:%S %Z")
else:
return datetime.datetime.strptime(s, "%a %b %d %H:%M:%S %Y")
while True:
line = sys.stdin.readline()
line = line.strip()
if line == '':
break
print(parse_http_datetime(line))