How do I parse a JSON response from Python Requests?

后端 未结 7 1231
悲&欢浪女
悲&欢浪女 2021-02-19 00:09

I am trying to parse a response.text that I get when I make a request using the Python Requests library. For example:

def check_user(s         


        
7条回答
  •  我寻月下人不归
    2021-02-19 00:37

    The manual suggests: if self.response.status_code == requests.codes.ok:

    If that doesn't work:

    if json.loads(self.response.text)['result'] == 'success':
       whatever()
    

提交回复
热议问题