摘要: 1.先来个不反爬的 """这个不设置反爬措施,练手最好用""" import requests from bs4 import BeautifulSoup response = requests.get("https://www.autohome.com.cn/news/") # 转换编码 resp 阅读全文
posted @ 2018-10-17 20:13 知你几分 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 1.自定义报错,不继承父类的方法就返回错误信息 class Base(object): def send(self): raise NotImplementedError('子类中必须实现send方法') class Foo(Base): """如果不写send方法,会返回错误信息""" def s 阅读全文
posted @ 2018-10-17 15:15 知你几分 阅读(607) 评论(0) 推荐(0) 编辑
摘要: 栈,先进后出或者后进先出,以列表的结构外加append和pop方法实现栈 class Stack: def __init__(self): # 实例一个空列表对象 self.items = [] def isEmpty(self): # 判断列表中是否有值,空就返回True return self. 阅读全文
posted @ 2018-10-17 14:43 知你几分 阅读(644) 评论(0) 推荐(0) 编辑