用python查看网页代码的方法:
1、使用“import”导入requests包
2、使用requests包的get()函数通过网页链接获取网页的源码,然后使用print()语句输出就可以了

执行结果如下:

实例扩展:
Python获取网页html代码
获取网页html代码:
import requests
res = requests.get('https://www.jb51.net/更换成你的网页.html')
res.encoding = 'utf-8'
print(res.text)
运行结果:
