章节目录 第34章 女娲补天(2 / 2)
作品:《呼叫统子,我带着财富当老师》self.app_key= app_key
self.data={}
def invoke(self, params):
self.url_data= urllib.parse.urlencode(params).encode(encoding='utf-8')
req= urllib.request.Request(self.url, self.url_data)
try:
rsp= urllib.request.urlopen(req)
str_rsp= rsp.read dict_rsp= json.loads(str_rsp.decode('utf-8'))
return dict_rsp
except urllib.error.URLError as e:
dict_error={}
if hasattr(e,"code"):
dict_error={}
dict_error['ret']=-1
dict_error['httpcode']= e.code
dict_error['msg']="sdk http post err"
return dict_error
if hasattr(e,"reason"):
dict_error['msg']='sdk http post err'
dict_error['httpcode']=-1
dict_error['ret']=-1
return dict_error
else:
dict_error={}
dict_error['ret']=-1
dict_error['httpcode']=-1
dict_error['msg']="system error"