我想将Python日期时间转换为RFC 2822日期时间。我已经试过这些方法都无济于事:将Python日期时间转换为rfc 2822
>>> from email.Utils import formatdate
>>> import datetime
>>> formatdate(datetime.datetime.now())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/email /utils.py", line 159, in formatdate
now = time.gmtime(timeval)
TypeError: a float is required
为什么不只是使用time.time()? – 2015-01-16 02:11:42
在3.3版本中'datetime'有'timestamp'方法,使得这个过程更快。 – 2015-09-11 15:42:28