w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python module "requests" returns different variable type in python version 3 and 2

You have to decode the bytes object in order to get a str. Something like bytes.decode('utf-8'), just with the right encoding.

>>> a.decode('utf-8')
>>> x = b'Hello'
>>> type(x)
<class 'bytes'>
>>> y = x.decode('utf-8')
>>> y
>>> type(y)
<class 'str'>

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.