Python Forum
Issues parsing the response from a request
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues parsing the response from a request
#4
(May-11-2019, 02:46 AM)garnold Wrote: I understand that the u is not an issue but I can't seem to parse this information out.
You get u'something' because you use Python 2,just stop using Python 2.
Python 3 has a new Unicode system,that's much improved over Python 2.
>>> import requests
>>> 
>>> buttonColor = 'Yellow'
>>> r = requests.post('http://httpbin.org/post', json={"buttonColor":buttonColor})
>>> r.status_code
200
>>> json_data = r.json()
>>> print(json_data['json'])
{'buttonColor': 'Yellow'}
>>> print(json_data['json']['buttonColor'])
Yellow
Reply


Messages In This Thread
RE: Issues parsing the response from a request - by snippsat - May-14-2019, 12:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  request.get to read large response pythonlearner1 7 3,434 Apr-05-2022, 08:21 PM
Last Post: pythonlearner1
  how can I correct the Bad Request error on my curl request tomtom 8 5,257 Oct-03-2021, 06:32 AM
Last Post: tomtom
  Unable to convert request response. johnboy1974 4 3,233 Apr-05-2021, 10:10 AM
Last Post: snippsat
  Empty response to request causing .json() to error t4keheart 1 10,290 Jun-26-2020, 08:35 PM
Last Post: bowlofred
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 4,015 Jun-18-2020, 08:07 AM
Last Post: buran
  Parsing Soap XML response grootkarzijn 7 15,825 Jun-14-2019, 01:30 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020