datetimeをLast-ModifiedやIf-Modified-Sinceの書式に変換

from datetime import datetime

d = datetime.now()
s = datetime.strftime(d, '%a, %d %b %Y %H:%M:%S GMT')
print s
# = >Wed, 24 Oct 2012 21:34:50 GMT

受け取った文字列をdatetimeに戻す場合はstrptime

d = datetime.strptime(s, '%a, %d %b %Y %H:%M:%S GMT' )
print d
# => 2012-10-24 21:34:50