上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 32 下一页
摘要: 解压缩zip文件 import zipfile import os.path import os class ZFile(object): """ 文件压缩 """ def zip_file(self, fs_name, fz_name): """ 从压缩文件 :param fs_name: 源文件 阅读全文
posted @ 2020-01-22 16:55 一只小小的寄居蟹 阅读(10186) 评论(1) 推荐(1)
摘要: 函数重做的装饰器 def retry_times(attempt): def decorator(func): def wrapper(*args, **kw): att = 0 while att < attempt: try: return func(*args, **kw) except Ex 阅读全文
posted @ 2020-01-20 17:22 一只小小的寄居蟹 阅读(141) 评论(0) 推荐(0)
摘要: 1.下载UnRAR.exe,与python文件放在同一目录下 2.使用rarfile模块 代码: def rar_f(self, fz_name, path): """ 解压缩文件 :param fz_name: zip文件 :param path: 解压缩路径 :return: """ flag 阅读全文
posted @ 2020-01-14 17:19 一只小小的寄居蟹 阅读(237) 评论(0) 推荐(0)
摘要: 查看一台机器是否为虚拟机 linux dmidecode -s system-product-name >注意:需root权限 物理机: DL 580 虚拟机: VMware Virtual Platform windows 在cmd环境下使用systeminfo查看 物理机: 系统制造商: To 阅读全文
posted @ 2019-12-18 17:43 一只小小的寄居蟹 阅读(662) 评论(0) 推荐(0)
摘要: xpath解析是我们在爬虫中最常用也是最通用的一种数据解析方式。 环境安装 pip install lxml 解析原理 使用通用爬虫爬取网页数据 实例化etree对象,且将页面数据加载到该对象中 使用xpath函数结合xpath表达式进行标签定位和指定数据提取 实例化etree对象 - 1.将本地的 阅读全文
posted @ 2019-12-17 14:31 一只小小的寄居蟹 阅读(648) 评论(0) 推荐(0)
摘要: requests库使用流程 使用流程/编码流程 1.指定url 2.基于requests模块发起请求 3.获取响应对象中的数据值 4.持久化存储 分析案例 需求:爬取搜狗首页的页面数据 # 爬取搜狗首页 import requests if __name__ == '__main__': # ste 阅读全文
posted @ 2019-12-12 17:03 一只小小的寄居蟹 阅读(849) 评论(0) 推荐(0)
摘要: windows (1)打开文件资源管理器(文件夹地址栏中) (2)地址栏上面输入 %appdata% (3)在这里面新建一个文件夹 pip (4)在pip文件夹里面新建一个文件叫做 pip.ini ,内容写如下即可 [global] timeout = 6000 index-url = https: 阅读全文
posted @ 2019-12-12 09:47 一只小小的寄居蟹 阅读(516) 评论(0) 推荐(0)
摘要: python对不同类型文件的字符查找 TXT文件: def txt_handler(self, f_name, find_str): """ 处理txt文件 :param file_name: :return: """ line_count = 1; file_str_dict = {} if os 阅读全文
posted @ 2019-12-11 10:06 一只小小的寄居蟹 阅读(1071) 评论(0) 推荐(0)
摘要: django生命周期 cbv模式 url view cbv.html select_related 和 prefetch_related 方法各有什么区别 django的form功能的好处: 阅读全文
posted @ 2019-10-15 21:11 一只小小的寄居蟹 阅读(193) 评论(0) 推荐(0)
摘要: 导入 Page对象 Paginator.page()将返回一个Page对象,我们主要的操作都是基于Page对象的,它具有下面的方法和属性: 方法: Page.has_next()[source]:如果有下一页,则返回True。 Page.has_previous()[source]:如果有上一页,返 阅读全文
posted @ 2019-10-13 15:26 一只小小的寄居蟹 阅读(878) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 32 下一页