utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:django-anymail 作者: anymail 项目源码 文件源码
def parse_rfc2822date(s):
    """Parses an RFC-2822 formatted date string into a datetime.datetime

    Returns None if string isn't parseable. Returned datetime will be naive
    if string doesn't include known timezone offset; aware if it does.

    (Same as Python 3 email.utils.parsedate_to_datetime, with improved
    handling for unparseable date strings.)
    """
    try:
        return parsedate_to_datetime(s)
    except (IndexError, TypeError, ValueError):
        # despite the docs, parsedate_to_datetime often dies on unparseable input
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号