def get(self, path, **kwargs): ''' get请求 :param path: 请求的资源路径 :param kwargs: 其他附加的HTTP参数列表(如header等) :return: response对象 ''' return requests.request( method='get', url=config.generate_api_url(path), headers=self._get_header, **kwargs )
def _post(self, path, data=None, method='post', **kwargs): ''' post, put, deleta等公用的内部方法 ''' post_data = data if post_data is not None: post_data = json.dumps(post_data) return requests.request( method=method, url=config.generate_api_url(path), data=post_data, headers=self._post_header, **kwargs )