utils.py 文件源码

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

项目:workflows.kyoyue 作者: wizyoung 项目源码 文件源码
def get_encoding_from_headers(headers):
    """Returns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    :rtype: str
    """

    content_type = headers.get('content-type')

    if not content_type:
        return None

    content_type, params = cgi.parse_header(content_type)

    if 'charset' in params:
        return params['charset'].strip("'\"")

    if 'text' in content_type:
        return 'ISO-8859-1'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号