11 2019 档案
摘要:``` import xlwings as xw #打开存好的excel app = xw.App() #设置应用 wb = xw.Book("E:/Data/小蜜蜂超市销售报表.xlsx") #打开文件 ws = wb.sheets['Sheet1'] #选择表格 last_column = ws.range(1, 1).end('right').get_address(0, 0)[0] #获取
阅读全文
摘要:1.利用key排序 d1 2 d2 4 d3 3 d4 1 2.利用value排序:__getitem__ d4 1 d1 2 d3 3 d2 4 反序: reverse=True d2 4 d3 3 d1 2 d4 1 3.对dict_items进行排序 [('d2', 4), ('d3', 3)
阅读全文
摘要:Request回调函数 传递参数
阅读全文
摘要:```
import scrapy from scrapy.spidermiddlewares.httperror import HttpError
from twisted.internet.error import DNSLookupError
from twisted.internet.error import TimeoutError, TCPTimedOutError class E...
阅读全文
摘要:步骤01: 创建项目 步骤02: 编写items.py 步骤03: 在spiders文件夹内创建articles.py 步骤04: 运行爬虫
阅读全文
摘要:步骤01: 创建项目 步骤02: 使用csvfeed模版 步骤03: 编写items.py 步骤04: 编写爬虫文件csvdata.py 步骤05: 运行爬虫文件
阅读全文
摘要:步骤01: 创建项目 步骤02: 使用XMLFeedSpider模版创建爬虫 步骤03: 修改items.py 步骤04: 配置爬虫文件jobbole.py
阅读全文
摘要:步骤01: 创建爬虫项目 步骤02: 创建爬虫模版 步骤03: 配置爬虫文件quotes.py 步骤04: 运行爬虫
阅读全文
摘要:解决:更新安装service_identity
阅读全文
摘要:在使用python的开发过程中,常常需要判断,字符串中是否存在子串的问题, 但判断一个字符串中是否存在多个字串中的一个时,如if (a or b) in c或者if x contains a|b|c|d…, 似乎就需要借助for做循环判断,那么这种情况有没有更pythonic的方法呢? 判断一个字符
阅读全文
摘要:保存数据到json文件
阅读全文
摘要:```
# -*- coding: utf-8 -*- # Define here the models for your spider middleware
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/spider-middleware.html from scrapy import signals
...
阅读全文
摘要:一、使用cookies登录网站 二、发送post请求登录, 要手动解析网页获取登录参数 三、发送post请求登录, 自动解析网页获取登录参数
阅读全文
摘要:```
# -*- coding: utf-8 -*- # Scrapy settings for maitian project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting t...
阅读全文
摘要:1.创建爬虫项目 2.创建爬虫文件 3.运行(crawl) 4.check检查错误 5.list返回项目所有spider 6.view 存储、打开网页 7.scrapy shell, 进入终端 8.scrapy runspider
阅读全文
摘要:首先创建项目: 第二步: 明确要抓取的字段 第三步: 在spider目录下创建爬虫文件: 2.1 创建一个类,并继承scrapy的一个子类: 2.2 自定义爬取名, 后面运行框架需要用到; 2.3 定义爬取目标网址 2.4 定义scrapy的方法 下面是简单项目: 第四步: 在 文件中设置数据保存到
阅读全文
摘要:报错内容: 解决方法: 将async替换就可以了(例如都改为shark),注意不要修改导入包的部分
阅读全文
摘要:1. 下载pip 地址: 注意选择tar.gz压缩包,目前最新版本为9.0.1,这里选择的版本是:pip 9.0.1.tar.gz (md5, pgp) 点击: "下载" 2. 解压安装 解压下载的压缩包至工作目录下(如D:\),打开Windows cmd,运行如下命令进入解压后的pip目录 使用如
阅读全文
摘要:``` 给出一组整数,将其按照升序排序 例如给出[3,2,1,4,5],排序后的结果为[1,2,3,4,5] 参数A是一个整数数组 返回一个整数数组 class Solution: def sortIntegers2(self,A): self.quickSort(A,0,len(A) 1) def
阅读全文
摘要:``` 示例: 输入num=16, 输出True, sqrt(16)=4; 输入num=15, 输出False, sqrt(15)=3.87 class Solution: def isPerfectSquare(self, num): l=0 r=num while (r l 1): mid=(l
阅读全文
摘要:``` class Solution: def checkPowerOf2(self, n): ans=1 for i in range(31): if ans == n: return True ans = ans
阅读全文
摘要:```
data_list=[] col=["a", "b", "c", "d"]
jdata={"a":1, "b":2, "c":3, "d":4} for j in jdata: result=[ j[h] and j.setdefault(h) if h in j.keys() else None for h in col] data_list.append(tuple...
阅读全文
摘要:https://www.zhihu.com/question/42768955/answer/94798842
阅读全文
摘要:``` list1 = ['122','2333','3444',' ','422',' ',' ','54',' '] list1=[x.strip() for x in list1 if x.strip() != ''] ```
阅读全文
摘要:简单使用 装饰器带有参数的函数 通用的装饰器 带有参数的装饰器
阅读全文
摘要:docker compose将解析版本为"2",而不是"3.3"。应该改为:
阅读全文
摘要:为了永久性保留更改,您可以修改 /etc/docker/daemon.json 文件并添加上 registry mirrors 键值。 修改保存后重启 Docker 以使配置生效。
阅读全文