自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【python小工具】chardet.detect 检测、转换文本编码

from chardet import detect as char_detectdef change_encode_type(file_path, des='utf-8'): # 获取原文本的编码类型 with open(file_path, 'rb') as f: detect_result = char_detect(f.read(200)) src = detect_result['encoding'].lower() print('

2021-08-06 18:27:07 1569

原创 【python小工具】itertools.groupby 按连续数分组,可设置步长

from itertools import groupbydef group_number(ls, step=1): """对连续数分组,step设置连续数的步长""" result = [] for _, i in groupby(map(lambda x: [x[0] * step, x[1]], enumerate(ls)), lambda x: x[1]-x[0]): result.append([j for _, j in i]) return

2021-08-06 17:40:21 522

原创 【mac】禁用烦人的系统快捷键(⌘M、 ⌘H....)

使用Alfred,完美解决

2021-05-18 13:57:06 1937 2

原创 【sublime】个性化配置

settings-User// 保存自动去除行末空格"trim_trailing_white_space_on_save": truekeymap-User// 代码格式化{ "keys": ["alt+shift+f"], "command": "reindent" },// 替换原功能transpose{ "keys": ["ctrl+t"], "command": "new_file" },// 隐藏行数{ "keys": ["alt+l"], "comma

2021-04-14 15:19:09 175

原创 【mac】navicat 保存密码失败 -34018

navicat 选择保存密码时会出现 Failed to save password Error code: -34018解决方法打开 钥匙串访问(keychain access)新建钥匙串输入钥匙串名称,将<连接名>替换成自己的输入数据库的用户名和密码保存重启navicatcom.prect.Navicat.conn {Conn:MySQL; Db:<连接名>; UserID:local; ProjectID:local}...

2021-03-30 09:32:35 9652 4

原创 【工具】三元运算符格式化

phpstorm遇到这种神级代码也无法进一步美化,只能借用在线工具pretty diff完成for (var n = 0; n < o.length; n++) "刷卡支付" == o[n].value ? 1 == i.skzf ? o[n].checked = !0 : o[n].checked = !1 : "免费wifi" == o[n].value ? 1 == i.wifi ? o[n].checked = !0 : o[n].checked = !1 : "免费停车" == o[n].

2021-03-28 18:49:03 571

原创 【php】获取access_token

function getAccessToken() { $table_name = 'xxx'; $system = pdo_get($table_name, ['id' => 1]); $token = $system['access_token']; // 校验是否失效 $check_url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=".$token; $res = se

2021-03-17 13:46:27 765

转载 【chmod】修改文件夹、子文件夹权限,不包含文件

How to recursively chmod all directories except files?To recursively give directories read&execute privileges:find /path/to/base/dir -type d -exec chmod 755 {} +To recursively give files read privileges:find /path/to/base/dir -type f -exec chmod 64

2021-03-01 10:28:26 741

原创 【mac.rpa】rpa.init()

tagui.py 路径 /usr/local/Cellar/anaconda/envs/your_env/lib/python3.7/site-packages/tagui.py下载TagUI_macOS.zip [150.5 MB]注释 if not os.path.isfile('rpa_python.zip')和else的代码注释# set correct tagui folder for different operating systems下的if platform.system()

2021-02-19 18:39:42 911 2

转载 【python】Install Certificates.command

来源:Install Certificates.command · GitHub# install_certifi.py## sample script to install or update a set of default Root Certificates# for the ssl module. Uses the certificates provided by the certifi package:# https://pypi.python.org/pypi/certi

2021-02-19 16:12:58 3471

原创 【python小工具】requests下载大文件,可代理,可续载

python requests库下载大文件,可代理,可续载

2021-02-08 20:29:58 1161

原创 【php.yii】Operator ‘FIND_IN_SET()‘ requires two operands.

$filter = ['and', ['=', 'is_del', 0], ['like', 'title', $where['title'] ?? ''], ['=', 'status', $where['status'] ?? ''], ['or', ['like', 'desc', $where['key'] ?? ''], ['like', 'content', $where['key'] ?? ''], ]];$tmp

2021-01-18 23:56:26 2122

原创 【js】获取表单name[]的数组

<input name="content[]" value="content1"><input name="content[]" value="content2"><script>content = $("input[name='content[]']");for (i=0; i < content.length; i++) { content[i] = content[i].value;}content = content.toArray()

2021-01-04 13:19:59 1544

原创 【公众号】获取用户信息

接口https://api.weixin.qq.com/cgi-bin/user/info?access_token=xxxxx&openid=xxxxx返回数据(关注中){ subscribe: 1, openid: "xx", tagid_list: [ ], nickname: "xx", sex: 1, language: "zh_CN", city: "", province: "", country: "中国", headimgurl: "http://thir

2020-12-28 16:29:28 229

原创 【php】phpstorm 快速插入 <?php ?>

2020-12-24 18:14:09 393 2

原创 【postman】传列表参数

参数后面加上[]

2020-12-15 15:45:29 1130

转载 【php小工具】文件大小单位转换

function convertFilesize($bytes, $decimals=2){ $size = ['B', 'kB', 'MB', 'GB', 'TB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];}

2020-12-14 17:23:10 110

原创 【php小工具】实用的字段映射方法

/** * 字段映射,配合映射字典 $field_map * [[目标字段$field, 检索模型$class, 检索字段$from(默认id), 取出字段$to(默认name)]] * * 例如 ["rid", Role::class, "id", "name"] * Role表检索 id=$data['rid'],取出 name,最后 $data['rid_t']=name */public static function fetchScalarByField($data, $field

2020-12-12 19:51:25 412

原创 【数据】全国省市区信息,mysql数据库记录

全国省市区信息,mysql数据库记录

2020-12-09 11:17:04 2000

原创 【php】下载文件

if (is_file($file)) { // 判断是否文件 bool header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=" . $file); readfile($file);}ZipArchive类打包多个文件public static function PackDown($file_arr, $download_n

2020-12-01 12:10:03 70

原创 【js】监听输入框,填入数据

$("#src_input").blur(function(){ var val = $(this).val(); if (val == '') return; $.ajax({ type: 'get', url: "/get-list", dataType : 'json', success: function(res) { if (res.code == 0){

2020-11-27 12:33:36 315

原创 【apache】切换php

# vim /etc/apache2/httpd.conf# 把下面一行注释掉,换成自己的php# LoadModule php7_module libexec/apache2/libphp7.soLoadModule php7_module local/php5-7.2.21-20190811-210031/libphp7.so

2020-10-22 19:33:56 129

原创 【mac.apache】报错 AH00557 AH00558

AH00557: httpd: apr_sockaddr_info_get() failed for liumoujiadeMacBook-Pro.localAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message原因是存在两

2020-10-22 18:56:09 1115 2

转载 【python小工具】vbb文件提取json

参考 github caltech-pedestrian-converterfrom scipy.io import loadmatimport osdef vbb2json(vbb_path): vbb = loadmat(vbb_path)['A'][0][0] nFrame = int(vbb[0][0][0]) objLists = vbb[1][0] maxObj = int(vbb[2][0][0]) objInit = vbb[3][0].

2020-10-21 19:56:25 709

原创 【python小工具】seq文件提取jpg图片

def seq2jpg(seq_path): with open(seq_path, 'rb') as f: seq = f.read() header = b"\xFF\xD8\xFF\xE0\x00\x10\x4A\x46\x49\x46" img_ls = seq.split(header)[1:] # 去掉第1个 # 保存在当前路径,新建同名文件夹 save_dir = seq_path[:-4] if not os.pa

2020-10-21 16:11:36 965 2

原创 【python小工具】zipfile打包指定文件

def make_zip(fp_ls, zip_path): """将指定文件打包成zip文件""" zipf = zipfile.ZipFile(zip_path, 'w') for file_path in fp_ls: file_name = os.path.split(file_path)[-1] zipf.write(file_path, file_name) zipf.close()

2020-10-21 10:09:15 156 1

原创 【python小工具】图片image由ndarray转换成bytes格式

def ndarray2bytes(img_arr): """ndarray的图片转换成bytes""" imgByteArr = io.BytesIO() Image.fromarray(img_arr).save(imgByteArr, format='PNG') img_data = imgByteArr.getvalue() return img_data

2020-10-16 11:54:06 1653

原创 【python小工具】递归遍历所有文件

import osdef get_file(dir): file_ls = [] for i in os.listdir(dir): new_path = os.path.join(dir, i) if os.path.isdir(new_path): file_ls.extend(get_file(new_path)) elif os.path.isfile(new_path): file_l

2020-10-13 20:44:52 153

原创 python 上传公众号图文素材报错:44003

报错: {“errcode”:44003,“errmsg”:“empty news data hint: [QGI6fA08690015]”}解决方法data是字符串格式,不是字典格式import jsondata = json.dumps(data, ensure_ascii=False).encode('utf-8')

2020-10-09 22:10:29 1150 1

原创 【web】视差滚动

效果无插件<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script><style type="text/css"> .parallax { height: 550px; background-attachment: fixed; background-size: cover; /* background-repeat: no-rep

2020-09-25 17:48:27 277

原创 【python小工具】图片生成滚动效果的gif

# 相关库import imageiofrom PIL import Image# 以下库用来识别图片主颜色import pandas as pdimport numpy as npdef img2gif(image, offset=10, from_='r', show_size=0, has_out=False, bgc=''): """ offset: 每次移动像素 from: l, r, u, d 对应左右上下 show_size: 滚动窗口大小

2020-09-21 20:54:15 990

原创 【python小工具】1行代码提取照片主要颜色

使用的图片准备# 相关库from PIL import Imageimport pandas as pdimport numpy as np# 打开图片img = Image.open(img_path)运行pd.Series([','.join(j) for i in np.array(img).astype('str') for j in i]).value_counts()[:5]前5种147,156,189 67150,155,185 53149,147

2020-09-21 16:52:07 432

原创 小程序读取本地json数据

/utils/data.jsvar json=[ { "cat_id": 1, "cat_name": "电视", }, { "cat_id ": 2, "name": "空调", }]// 定义数据出口module.exports = { dataList: json}/pages/index/index.jsonLoad: function (options) { var d

2020-08-09 12:17:15 2223 1

原创 subplots, subplot, axes的参数和属性

set属性  set_adjustable{‘box’, ‘datalim’}set_agg_filtera filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) arrayset_alphafloat or Noneset_anchor2-tuple of floats or {‘C’, ‘SW’, ‘S’

2020-07-17 12:14:58 4231

原创 【python.matplotlib】tick_params参数

参数说明axis{‘x’, ‘y’, ‘both’}, optional坐标轴;默认 ‘both’.resetbool, default: FalseIf True, set all parameters to defaults before processing other keyword arguments.which{‘major’, ‘minor’, ‘both’}主、副刻度线;默认 ‘major’direction{‘in’, ‘out’, ‘inou...

2020-07-17 11:44:58 2654

原创 【python.matplotlib】显示标签在线条上

线条中间使用 matplotlib-label-lines 库from labellines import labelLines # pip install matplotlib-label-linesfrom matplotlib.dates import date2numfrom datetime import datetimedf = pd.DataFrame([[0, 2, 4], [3, 3, 3], [4, 3, 2]], columns=['A

2020-07-14 21:31:20 4789 1

转载 决策树可视化

import pydotplusfrom IPython.display import Imagefrom sklearn.tree import export_graphviz# Graphviz临时环境变量import osos.environ['PATH'] += r'.\Graphviz2.38\bin'def print_graph(dtr, feature_names): """绘制决策树""" graph = export_graphviz(dtr, featu

2020-07-12 23:42:45 167

原创 pandas分块处理数据

之前数据列太多,独热编码内存不够,想着分块处理。但我选出一些关键特征列后结果还好,以下方法没有实际用过。from sklearn.model_selection import train_test_split# 设置随机种子SEED = 0np.random.seed(SEED)def get_train_test(chunk, test_size=0.95, SEED=SEED): """划分训练集测试集""" y = 1 * (chunk['target'] == "REP

2020-07-12 22:48:13 724

原创 【pandas】DataFrame去掉整列相同的数据

法一不适用于字符串类型的数据X.drop(X.columns[X.std() == 0], axis=1, inplace=True)法二通用X = X.loc[:, (X != X.iloc[0]).any()]

2020-07-12 22:27:13 1672

原创 matplotlib隐藏刻度线、标签和边线

一般情况plt.figure(figsize=(3, 3))plt.plot([0, 1], [0, 1])隐藏所有刻度线和标签plt.axis('off')隐藏刻度线默认左下True 右上Falseplt.tick_params(bottom=False, top=False, left=False, right=False)隐藏边线ax = plt.gca()for i in ['top', 'right', 'bottom', 'left']: ax.spine

2020-07-11 23:24:05 24560 2

空空如也

空空如也

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

TA关注的人

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