models.py 文件源码

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

项目:trip 作者: littlecodersh 项目源码 文件源码
def apparent_encoding(self):
        """The apparent encoding, provided by the chardet library."""
        def _encoding(content):
            return chardet.detect(content)['encoding']

        @gen.coroutine
        def _stream_apparent_encoding():
            content = yield self.content
            raise Return(_encoding(content))

        if not isinstance(self.raw, HTTPMessageDelegate):
            raise TypeError('self.raw must be a trip.adapters.MessageDelegate')

        if self.raw.stream:
            return _stream_apparent_encoding()
        else:
            return _encoding(self.content)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号