python
dejavu111
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
random.sample()函数和str的join()函数
题目: 随机生成100个统一号码段的(比如180)手机号码 random.sample(‘sequence’, x) 代码: import random for i in range(0,100): list1 = random.sample(range(0,10), 8) list2 = [str(x) for x in list1] #将list1中整型元素转为s...原创 2018-08-27 14:00:43 · 3865 阅读 · 3 评论 -
python __init__和__new__
object.new(cls[, …]) 调用以创建类 cls 的新实例。new() 的返回值应该是新的对象实例(通常是 cls 的实例)。 典型的实现通过使用具有适当参数的 super(currentclass, cls).new(cls[, …]) 调用超类的 new() 方法来创建该类的新实例,然后在返回之前根据需要修改新创建的实例。 如果 __new__() 返回 c...原创 2018-09-01 13:26:21 · 172 阅读 · 0 评论 -
TypeError:write() argument must be str, not bytes
class ItcastPipeline(object): def init(self): self.f = open(“itcast_pipelines.json”,“w”) def process_item(self, item, spider): content = json.dumps(dict(item), ensure_ascii=False) + ", \n" sel...原创 2018-10-19 14:16:46 · 173 阅读 · 0 评论 -
scrapy笔记
xpath(): 传入xpath表达式,返回该表达式所对应的所有节点的selector list列表 。 css(): 传入CSS表达式,返回该表达式所对应的所有节点的selector list列表. extract(): 序列化该节点为unicode字符串并返回list。 re(): 根据传入的正则表达式对数据进行提取,返回unicode字符串list列表。 打印日志 self.log(“xx”...原创 2019-01-15 16:04:26 · 211 阅读 · 0 评论
分享