# _*_ coding::utf_8 _*_ import urllib.request import urllib.parse url="https://www.bilibili.com/" headers={ 'User-Agent':'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 ' } request=urllib.request.Request(url=url,headers=headers) # url=url,headers=headers要写全 response=urllib.request.urlopen(request) print(response.read().decode())