I am learning the urllib library. I use the following code to request the home page of the face degree, and the result is < class" bytes" >. I have tried a variety of methods to decode it, but all of them are unsuccessful (error or null)
the following code:
from urllib import request
f = request.urlopen("http://www.baidu.com/")
print(f.read())
print(type(f.read()))
x = f.read()
print(x.decode(encoding="utf-8"))
the following is the output:
. N < / body > n < / html > nrnrnrnnrn"
< class" bytes" >
"
Please give me your advice, thank you!