-2

I'm using:

import requests

data = 'text=great'

print(requests.post('http://text-processing.com/api/sentiment/', data=data).text)

which returns:

{"probability": {"neg": 0.30135019761690551, "neutral": 0.27119050546800266, "pos": 0.69864980238309449}, "label": "pos"}

and I want to browse that using the structure not just as a string of text. How can I turn it into a dictionary?

Crizly
  • 971
  • 1
  • 12
  • 33

1 Answers1

2

Use the json() method which would load the JSON response content and return you a Python data structure:

response = requests.post('http://text-processing.com/api/sentiment/', data=data)
print(response.json())
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195