Essentially I made a request to a website and got a byte response back: b'[{"geonameId:"703448"}..........'.
I'm confused because although it is of type byte, it is very human readable and appears like a list of json. I do know that the response is encoded in latin1 from running r.encoding
which returned ISO-859-1
and I have tried to decode it, but it just returns an empty string. Here's what I have so far:
r = response.content
string = r.decode("ISO-8859-1")
print (string)
and this is where it prints a blank line.
However when I run
len(string)
I get: back 31023
How can I decode these bytes without getting back an empty string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…