- 博客(4)
- 收藏
- 关注
原创 python报错: can't send non-None value to a just-started generator
def gen(): x =0 while True: x = yield x*xa = gen()# next(a)time.sleep(3)for i in range(5): print(a.send(i))在一个生成器函数未启动之前,是不能传递数值进去。必须先传递一个None进去或者调用一次next(g)方法,才能进行传值操作...
2019-01-11 08:48:08
633
原创 python 装饰器
多层装饰器原理最外层接收装饰器的参数第二层传递函数, 返回值为下一层函数,不调用其他内层返回下一层函数的调用最内层包装被装饰的函数, 如果被装饰的函数有返回值则返回def one(args, cc): print('----args--', args, cc) def two(func): print('----two') def th...
2018-12-20 22:16:06
144
原创 python MongoCache
class MongoCache(object): """ 数据库缓存 """ def __init__(self,client=None,expires=timedelta(days=30)): self.client = MongoClient("localhost",27017) self.db = self.client.ca...
2018-12-20 18:19:56
211
1
原创 爬虫第一天
爬虫步骤:1. 导入requestsimport requests2. url和请求头url = 'http://example.webscraping.com/places/default/user/login' #要请求的页面地址headers = {'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Geck...
2018-12-17 21:30:27
156
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人