如何打印返回的对象?

2024-05-23 21:52:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我在自定义函数中使用requests库:

def add_advert(self, json_data):
       headers = {'Content-Type': 'application/json'}
       return requests.post(self.base_url + self.api_urls["add_advert"], 
  json=json_data, headers=headers,
                          auth=(self.api_key, ''))

并调用此函数:

response = api.add_advert(json_data=json_data)

如何显示变量response的内容

我试过:打印response.content,打印response.json


Tags: 函数selfaddapijsondatareturnapplication