Python urllib request urlopen request web page returns bytes type

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!


the first call to read () returns, and the subsequent calls always return baked'

.

urllib requests

import requests
response = requests.get('https://www.baidu.com/')
response.encoding = 'utf-8'
print(response.text)
Menu