0

i'm receiving a dict from an api call like this:

response_dict = { u'somekey': { u'fu': u'bar' } }

All strings are in unicode and i want to do calculations with them, but I need them as str for that.

Do I really have to cast them all manually to str?

The api library isn't working for python 3.6 (where probably all values would have been in str already).

Thanks for help, Phil

ThinkTeamwork
  • 544
  • 5
  • 19
  • I don't think you need to convert any of them to str. Most operations that work on `str` can handle Unicode too. Are you running into implicit encoding or decoding issues? – Martijn Pieters Nov 16 '17 at 18:27
  • What sort of "calculations" are you doing that require bytes? Are the strings guaranteed to be ascii only? – ekhumoro Nov 16 '17 at 18:30
  • thanks guys, i realized its duplicate question. the other link really helped me! – ThinkTeamwork Nov 16 '17 at 18:32

0 Answers0