提问:
python
问题背景
学习编写爬虫的过程中只显示进程已结束,退出代码0,代码无报错
import requests #导入模块 if __name__=="main ": url = 'https://www.baidu.com/' #step1指定URL response = requests.get(url=url) #step2发送请求 print(response) page_text = response.text #step3获取相应数据 print(page_text) with open('./baidu.html',encoding='utf-8') as fp: fp.write(page_text) #step4持久化存储 print('任务完成')
结果:
解答:
if __name.....这行你写的有问题,你的两个短下划线看着不对,你看上面那个图。
标签:__,text,代码,print,报错,进程,response From: https://www.cnblogs.com/dituirenwu/p/17065462.html