__init__.py 文件源码

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

项目:mygene.py 作者: biothings 项目源码 文件源码
def _get(self, url, params={}, none_on_404=False, verbose=True):
        debug = params.pop('debug_get', False)
        return_raw = params.pop('return_raw', False)
        headers = {'user-agent': "mygene.py/%s python-requests/%s" % (__version__, requests.__version__)}
        res = requests.get(url, params=params, headers=headers)
        from_cache = getattr(res, 'from_cache', False)
        if debug:
            return from_cache, res
        if none_on_404 and res.status_code == 404:
            return from_cache, None
        if self.raise_for_status:
            # raise requests.exceptions.HTTPError if not 200
            res.raise_for_status()
        if return_raw:
            return from_cache, res.text
        ret = res.json()
        return from_cache, ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号