【发布时间】:2019-02-09 01:53:45
【问题描述】:
我收到错误 AttributeError: 'Response' 对象对于我编写的以下代码没有属性'get'
def convert_json(self,bucket,userid,imgfilename,field,i):
bucketName = bucket
link = "users_"+str(userid)+'/'+imgfilename
c = S3Connection(self.AWS_ACCESS_KEY_ID,self.AWS_ACCESS_KEY_SECRET)
p = c.generate_url(expires_in=long(7200),method='GET',bucket=bucketName,key=link,query_auth=True,force_http=False)
post_url = "http://someurl"
wrapper = {"filename":p}
try:
response = requests.post(post_url, json=wrapper)
print response
if response.status_code == 200:
text = response.get('description', [])
else:
text = []
except Exception:
if response.status_code == 200:
text = response.get('description', [])
else:
text = []
return text
【问题讨论】: