import time
import giphy_client
from giphy_client.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = giphy_client.DefaultApi()
api_key = 'dc6zaTOxFJmzC' # str | Giphy API Key.
q = 'cheeseburgers' # str | Search query term or prhase.
limit = 1 # int | The maximum number of records to return. (optional) (default to 25)
offset = 0 # int | An optional results offset. Defaults to 0. (optional) (default to 0)
rating = 'g' # str | Filters results by specified rating. (optional)
lang = 'en' # str | Specify default country for regional content; use a 2-letter ISO 639-1 country code. See list of supported languages <a href = \"../language-support\">here</a>. (optional)
fmt = 'json' # str | Used to indicate the expected response format. Default is Json. (optional) (default to json)
try:
# Search Endpoint
api_response = api_instance.gifs_search_get(api_key, q, limit=limit, offset=offset, lang=lang, fmt=fmt)
#pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->gifs_search_get: %s\n" % e)
api_response['data']你好,我想不出如何将内联响应的api_response转换成我可以操作的东西,比如python字典。我需要找到一种方法来保存或转换它。我只能在自动取款机上打印。
谢谢!

发布于 2018-03-11 01:45:31
我想出了一种方法来提取数据
x = api_response.data
y = x[0]
y.images.downsized.url不确定这是不是最好的方法,但它对我来说是有效的!
发布于 2020-10-07 19:02:05
https://stackoverflow.com/questions/49212062
复制相似问题