自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

转载 python静态方法

本文链接:https://blog.csdn.net/jiangjunshow/article/details/950...

2019-09-11 10:41:39 321

原创 itemloader中更换response参数

在解析网页的时候, item loader的response参数并不适合, 只要将selector换成对应的解析的起点就可以了, add_xpath就从指定的节点开始匹配了 build_divs = response.xpath("//div[@class='notice']/..") for div in build_divs: fangitem...

2019-03-09 22:14:35 257

原创 Ubuntu/scrapy中ModuleNotFoundError: No module named '_sqlite3'错误

sudo apt-get install libsqlite3-dev进入python3所在目录重新编译,就是有configure那个文件夹sudo ./configuresudo makesudo makeinstall之后就可以继续嗨配了

2019-03-09 10:41:26 875

原创 继承传参个数

python中 super().init(参数), 多继承时需要将父类所有参数在子类中传递, 单继承时只能传递父类方法所需的参数

2019-03-03 10:22:36 162

原创 python深拷贝浅拷贝的简单总结

import copya = [“9”, “9”, “9”]b = [6,6,6,a]c = copy.copy(b)d = copy.deepcopy(b)这里bcd都属于顶层的同一层,深浅拷贝顶层的内存地址都改变了也就是bcd各自有自己的内存地址,所以改变b[0],对cd没有影响b[0] = 1print©print(d)由于c是浅拷贝的结果,内部结构的内存地址没有改变,所以...

2019-03-02 22:37:28 72

原创 python中静态方法什么时候用

class StaticMehtod(object):这个静态方法内部只使用了传进来的x和y, 而没有使用实例对象self@staticmethoddef plus_num(x, y): return x + ydef instance_method(self, x, y): return self.plus_num(x, y)print(StaticMehtod()...

2019-02-28 22:13:35 2747

原创 re.S 和 re.M的一点区别

s = ‘hello1world\nhello2world\nhello3world’#re.M 多行模式result1 = re.findall(r’\d.*d’, s, re.M)print(result1)#re.S 单行模式(可以看成将所有的字符串放在一行内匹配包括换行符\n)result2 = re.findall(r’\d.*d’, s, re.S)print(result...

2019-02-16 22:06:37 2961 2

原创 关于下标越界的小问题

li = [1,2,3,4,5,6,7,8,9,10]for i in range(0, len(li)-1, 2):print(i, li[i], li[i+1])关于下标越界,有时需要取出相邻对应的全部奇偶项, li的长度是10, 下标最大是9,所以i+1=9, 所以i最大是8, 所以range上届应该是9,len(li)需要减1...

2019-02-14 17:24:36 845

转载 python随机生成一个chrome的User-Agent

import randomdef get_ua():first_num = random.randint(55, 62)third_num = random.randint(0, 3200)fourth_num = random.randint(0, 140)os_type = [‘(Windows NT 6.1; WOW64)’, ‘(Windows NT 10.0; WOW64)’...

2019-02-13 16:23:27 876

原创 随机执行一个函数

def a():print(‘a’)def b():print(‘b’)def c():print(‘c’)func_list = [a, b, c]random.choice(func_list)()可以改成随机生成一个User-Agent的请求头,各浏览器请求头格式内容不同,所以用不同的函数...

2019-02-13 16:03:09 659

原创 python多列表对应元素生成新列表

方法1.multi_list = [[a, b, c, d, e] for a, b, c, d, e in zip( list1, list2, list3, list4, list5)]方法2.list1 = [1, 2, 3, 4, 5]list2 = [1, 2, 3, 4, 5]list3 = [1, 2, 3, 4, 5]multi_list = map(list, z...

2018-11-27 21:34:12 5537

原创 python -- TypeError: ‘NoneType’ object is not iterable

Type错误:“NoneType”对象不是可迭代的一般出现在将None返回给了多个值遍历的对象为None例 : item = Nonefor i in item:print(i)解决 :加判断item是否为None即可...

2018-11-20 10:59:09 7215

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除