01 2021 档案
摘要:python字典遍历的几种方法 (1)遍历key值 >>> a {'a': '1', 'b': '2', 'c': '3'} >>> for key in a: print(key+':'+a[key]) a:1 b:2 c:3 >>> for key in a.keys(): print(key+
阅读全文
摘要:这篇文章主要介绍了Python 列表(List) 的四种遍历方法实例 详解的相关资料,需要的朋友可以参考下 分别是:直接遍历对象 通过索引遍历 通过enumerate方法 通过iter方法。 使用Python遍历List四种方法代码如下: def text2(self): li = ['a', 'b
阅读全文
摘要:1、交换两个变量 # a = 4 b = 5 a,b = b,a # print(a,b) >> 5,4 让我们通过交换两个变量作为一个简单的开始。 此方法是最简单、最直观的方法之一,无需使用临时变量或应用算术操作即可编写。 2、多个变量赋值 a,b,c = 4,5.5,'Hello' #print
阅读全文
摘要:玩转正则表达式 本文中介绍的是主要是 3 个知识点: 正则表达式的相关知识 Python的中 re 模块,主要是用来处理正则表达式 一个利用 re 模块通过正则表达式来进行网页数据的爬取和存储 1、正则表达式 1.1 正则表达式及作用 正则表达式的英文是 regular expression,通常简
阅读全文
摘要:URL参数请求: import requests ''' URL Parameters 请求方式:URL参数 例如: 以get 方式请求http://httpbin.org/get?first_name=hello&last_name=word ''' # params={"first_name":
阅读全文
摘要:一、选取节点常用的路径表达式: 表达式 描述 实例 nodename 选取nodename节点的所有子节点 xpath(‘//div’) 选取了div节点的所有子节点 / 从根节点选取 xpath(‘/div’) 从根节点上选取div节点 // 选取所有的当前节点,不考虑他们的位置 xpath(‘/
阅读全文
摘要:标准选择器 可根据标签名、属性、内容查找文档 注意这里class 为python 的关键字 需要加入下划线_ find_all( name , attrs , recursive , text , **kwargs ) name html=''' <div class="panel"> <div c
阅读全文
摘要:实例: 匹配标签 匹配title标签 匹配网页的 <title></title> 标签,也就是网页的标题。 .*? 就是匹配1个或多个字符,也就是这里不能是空的。当加入括号的话,就是代表取值了 (.*?) import re import requests resp=requests.get("ht
阅读全文
摘要:抓取天气 import requests from bs4 import BeautifulSoup # from pyecharts import Bar cities_temp = [] # 处理抓取页面 def parse_url(url): headers = {"User-Agent":
阅读全文
摘要:案例 import requests import os from requests.packages import urllib3 from pyquery import PyQuery as pq import re # 解析数据 import ssl os.chdir(r"E:/pics222
阅读全文
摘要:案例 from selenium import webdriver from selenium.webdriver.common.keys import Keys # 键盘按键操作 import time def get_goods(driver): try: goods = driver.find
阅读全文
摘要:案例 import os from hashlib import md5 from selenium import webdriver import requests from lxml import etree # 首页请求 def get_response(url): headers = {"u
阅读全文
摘要:tags: #正则表达式 #HTML提取 匹配任意字符不能跨行:.* 匹配任意字符包括换行符等:[\s\S]* 捕获某前缀与某后缀之间的任意字符:(.*?) 使用情况举例,捕获下面HTML中的文字“不迟any” HTML:<a href='http://www.cnblogs.com/buchian
阅读全文
摘要:https://mp.weixin.qq.com/s/IqvY2c0PB5MGr55-B7rW4Q
阅读全文
摘要:查看hbase表大小。 进入 hbase 所在服务器 hbase shell 进入 hbase 库 list_namespace 列出所有命名空间 describe_namspace 'hbase' 查看指定命名空间 list_namespace_table 'default' 查看指定命名空间下的
阅读全文
摘要:https://mp.weixin.qq.com/s/BRgsKmvrZWeqrb-E0hlr4A
阅读全文
摘要:https://mp.weixin.qq.com/s/O2PubmG_q8gxxl8LKQ3fjg 创建SpringBoot项目 然后创建Controller、Mapper、Service包 SpringBoot整合Redis 引入Redis依赖 <!--SpringBoot与Redis整合依赖--
阅读全文
摘要:https://mp.weixin.qq.com/s/vdeeypw5juuveY_NEtS1tA 与前端对接的API接口,如果被第三方抓包并进行恶意篡改参数,可能会导致数据泄露,甚至会被篡改数据,我主要围绕时间戳,token,签名三个部分来保证API接口的安全性 1.用户成功登陆站点后,服务器会返
阅读全文
摘要:什么是正则表达式? 正则表达式(Regular Expression)通常被用来检索、替换那些符合某个模式(规则)的文本。 此处的Regular即是规则、规律的意思,Regular Expression即“描述某种规则的表达式”之意。 本文收集了一些常见的正则表达式用法,方便大家查询取用,并在最后附
阅读全文
摘要:https://mp.weixin.qq.com/s/n2-Ottx6Pqu9gR_JfUVkvA https://mp.weixin.qq.com/s/wqZnbzBL9aVNn42K9XUoSA https://www.cnblogs.com/psyche61/p/10737530.html h
阅读全文
摘要:java8自带常用的函数式接口 Predicate<T> boolean test(T t) 传入一个参数返回boolean值 Consumer<T> void accept(T t) 传入一个参数,无返回值 Function<T,R> R apply(T t) 传入一个参数,返回另一个类型 准备数
阅读全文
摘要:<!-- profiles.active默认激活dev --> <profiles> <profile> <!-- 声明这个profile的id身份 --> <id>dev</id> <!-- 默认激活:比如当知心mvn package命令是,没有传入参数,默认使用这个 当使用mvn package
阅读全文
摘要:创建工程 首先是创建工程,和前文一样,创建工程时,也是选择 Web、Jdbc 以及 MySQL 驱动,如下图: 创建成功之后,一定接下来手动添加 Druid 依赖,由于这里一会需要开发者自己配置 DataSoruce,所以这里必须要使用 druid-spring-boot-starter 依赖,而不
阅读全文
摘要:文章目录 一、方法说明 1、shutdown():停止接收新任务,原来的任务继续执行 2、shutdownNow():停止接收新任务,原来的任务停止执行 3、awaitTermination(long timeOut, TimeUnit unit):当前线程阻塞 二、区别 1、shutdown()
阅读全文
摘要:随机数 //进入发送逻辑的时候生成随机验证码,六位数字sale = RandomStringUtils.randomNumeric(6); 随机数范围 import java.util.Random; public class RandomUtil { public static Integer g
阅读全文
摘要:图片下载工具类 package com.zxwa.ntmss.img2text.utils; import cn.hutool.core.util.StrUtil; import com.zxwa.ntmss.process.config.OcrConfig; import org.slf4j.Lo
阅读全文
摘要:pom <!-- logback+slf4j --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <depen
阅读全文
摘要:来自 https://www.redis.net.cn/tutorial/3503.html https://www.cnblogs.com/zhou-zr/p/14691939.html https://files.cnblogs.com/files/luweiweicode/redis-3.0.
阅读全文
摘要:String.format()字符串常规类型格式化的两种重载方式 format(String format, Object… args) 新字符串使用本地语言环境,制定字符串格式和参数生成格式化的新字符串。 format(Locale locale, String format, Object… a
阅读全文
摘要:Redis生成分布式环境下自增ID 1. 需求明确 我们生成的Id组成为, 时间戳+ 自增Id, 补0 例如: 今天是2020.2.28 , 补6个0 , 那么生成的id范围是20200228000001-202002289999999 2.技术选型 Redis中的RedisAtomicLong 具
阅读全文
摘要:pom <!-- Redis 官方提供的 Java 驱动 --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <
阅读全文
摘要:package com.zxwa.ntmss.process.common.util; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONO
阅读全文
摘要:1.以下是封装了ES常用的基本方法,可以用来做一些简单的测试。 如:获取ES的TransportClient/IndicesAdminClient、判定索引是否存在、创建索引、设置mapping、删除索引、插入文档。 package com.bas.util; import org.elastics
阅读全文
摘要:"mappings": { "player": { "properties": { "name": { "index": "not_analyzed", "type": "string" }, "age": { "type": "integer" }, "salary": { "type": "in
阅读全文