我想將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