-3

so i do this get request to a Steam page where it responds this JSON:

{"success":true,"lowest_price":"$2.23","volume":"2,842","median_price":"$2.24"}

My objective is to transform it into a dictionary in Python, but what i get when i return the JSON object in my function is this:

{u'volume': u'2,842', u'median_price': u'2,02€ ', u'lowest_price': u'1,99€ ', u'success': True} (notice the u').

What can i do to eliminate the u's?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47

2 Answers2

1

You're seeing Python letting you know that the strings you're printing are unicode strings. Unless the output you're seeing really matters (e.g., it's input for something else), you can generally disregard the leading 'u' character until you run into issues with unicode output.

There are a litany of stack overflow questions which address this.

And a lot more....

Community
  • 1
  • 1
bmhkim
  • 754
  • 5
  • 16
0

You could import json module and use json.dumps to prettify your output.

import json
response = {"success":True,"lowest_price":"$2.23","volume":"2,842","median_price":"$2.24"}
print json.dumps(response, indent=2)
Kun
  • 1
  • 1