首页
畅所欲言
友情链接
壁纸大全
数据统计
推荐
工具箱
在线白板
Search
1
职教云小助手重构更新,职教云助手最新版下载地址【已和谐】
14,232 阅读
2
职教云-智慧职教,网课观看分析(秒刷网课)
11,468 阅读
3
gradle-5.4.1-all.zip下载
9,507 阅读
4
职教云-智慧职教,签到补签分析(逆天改命系列)
8,203 阅读
5
一个优秀的程序员从写文档开始:免费领14个月语雀云笔记会员
7,017 阅读
学习笔记
Web
Python
转载文章
算法刷题
JS逆向
综合笔记
安卓
物联网
Java
C
资源收集
软件收藏
网络资源
影视专辑
TED英语角
随便写写
随手拍
登录
/
注册
Search
Lan
累计撰写
617
篇文章
累计收到
629
条评论
首页
栏目
学习笔记
Web
Python
转载文章
算法刷题
JS逆向
综合笔记
安卓
物联网
Java
C
资源收集
软件收藏
网络资源
影视专辑
TED英语角
随便写写
随手拍
页面
畅所欲言
友情链接
壁纸大全
数据统计
推荐
工具箱
在线白板
搜索到
452
篇与
的结果
2021-07-01
复制粘贴插件——clipboard.js的使用
clipboard.js为什么将文本复制到剪贴板应该不难。它不应该需要几十个步骤来配置或加载数百 KB。但最重要的是,它不应该依赖于 Flash 或任何臃肿的框架。这就是 clipboard.js 存在的原因。安装你可以在 npm 上得到它。npm install clipboard --save或者,如果您不喜欢包管理,只需 https://github.com/zenorocha/clipboard.js/archive/master.zip 。设置首先,包含位于dist文件夹中的脚本或从 第三方 CDN 提供商 加载它。<script src="dist/clipboard.min.js"></script>现在,您需要通过传递 DOM 选择器、HTML 元素或HTML 元素列表来实例化它。new ClipboardJS('.btn');在内部,我们需要获取与您的选择器匹配的所有元素,并为每个元素附加事件侦听器。但猜猜怎么了?如果您有数百个匹配项,则此操作会消耗大量内存。出于这个原因,我们使用事件委托,将多个事件侦听器替换为单个侦听器。毕竟,#perfmatters。用法我们正在经历一个声明式的复兴,这就是为什么我们决定利用HTML5 数据属性来提高可用性。从另一个元素复制文本一个非常常见的用例是从另一个元素复制内容。您可以通过data-clipboard-target在触发器元素中添加属性来实现。您在此属性中包含的值需要与另一个元素选择器相匹配。<!-- Target --> <input id="foo" value="https://github.com/zenorocha/clipboard.js.git"> <!-- Trigger --> <button class="btn" data-clipboard-target="#foo"> <img src="assets/clippy.svg" alt="Copy to clipboard"> </button>从另一个元素剪切文本此外,您可以定义一个data-clipboard-action属性来指定您是否想要copy或cut内容。如果省略此属性,copy将默认使用。<!-- Target --> <textarea id="bar">Mussum ipsum cacilds...</textarea> <!-- Trigger --> <button class="btn" data-clipboard-action="cut" data-clipboard-target="#bar"> Cut to clipboard </button>正如您所料,该cut操作仅适用于或元素。从属性复制文本事实是,您甚至不需要另一个元素来复制其内容。您可以只data-clipboard-text在触发器元素中包含一个属性。<!-- Trigger --> <button class="btn" data-clipboard-text="Just because you can doesn't mean you should — clipboard.js"> Copy to clipboard </button>活动在某些情况下,您希望显示一些用户反馈或捕获复制/剪切操作后选择的内容。这就是为什么我们会触发诸如success和 之类的自定义事件以error供您聆听和实现您的自定义逻辑。var clipboard = new ClipboardJS('.btn'); clipboard.on('success', function(e) { console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger); e.clearSelection(); }); clipboard.on('error', function(e) { console.error('Action:', e.action); console.error('Trigger:', e.trigger); });高级用法如果您不想修改 HTML,可以使用非常方便的命令式 API。你需要做的就是声明一个函数,做你的事情,然后返回一个值。例如,如果您想动态设置 a target,则需要返回一个 Node.js 。new ClipboardJS('.btn', { target: function(trigger) { return trigger.nextElementSibling; } });如果您想动态设置 a text,您将返回一个字符串。new ClipboardJS('.btn', { text: function(trigger) { return trigger.getAttribute('aria-label'); } });要在 Bootstrap Modals 或任何其他更改焦点的库中使用,您需要将焦点元素设置为container值。new ClipboardJS('.btn', { container: document.getElementById('modal') });此外,如果您正在使用单页应用程序,您可能希望更精确地管理 DOM 的生命周期。以下是清理我们创建的事件和对象的方法。var clipboard = new ClipboardJS('.btn'); clipboard.destroy();
2021年07月01日
553 阅读
0 评论
0 点赞
2021-06-30
Zblog迁移至Typecho,Python脚本
注意,迁移之前一定要全部备份。我在迁移评论的时候不小心把旧博客的评论表数据给清空了,还好有数据备份。文章迁移脚本此脚本需要先将分类表手动迁移,注意ID以及名称要和原来的一致# -*- coding: utf-8 -*- """ ------------------------------------------------- @ Author :Lan @ Blog :www.lanol.cn @ Date : 2021/6/29 @ Description:I'm in charge of my Code ------------------------------------------------- """ import time import pymysql HOST = "数据库HOST地址" USER = "数据库用户名" PASSWORD = "数据库密码" PORT = 数据库端口 db = pymysql.connect(HOST, USER, PASSWORD, "旧数据库名称", PORT, charset='utf8') selectSql = "select * from zbp_post where log_cateID!=0 and log_ID!=436" cursor = db.cursor() cursor.execute(selectSql) source = cursor.fetchall() db.close() db = pymysql.connect(HOST, USER, PASSWORD, "新数据库名称", PORT, charset='utf8') cursor = db.cursor() a = 1 for i in source: cid = i[0] title = i[9].replace("'", '"') slug = i[0] created = i[12] modified = i[12] text = i[11].replace('{#ZC_BLOG_HOST#}', '新的博客地址') order = 0 authorid = 1 template = None type = 'post' status = 'publish' password = '' commentsNum = i[13] allowComment = 1 allowPing = 1 allowFeed = 1 parent = 0 views = i[14] agree = 0 try: insertSql = f"INSERT INTO typecho_contents VALUES({cid},'{title}','{slug}','{created}','{modified}','{text}','{order}','{authorid}',NULL,'{type}','{status}','{password}','{commentsNum}','{allowComment}','{allowPing}','{allowFeed}','{parent}','{views}','{agree}') " cursor.execute(insertSql) insertSql = f"Insert into typecho_relationships values('{cid}','{i[1]}')" cursor.execute(insertSql) db.commit() print(f'{cid}迁移成功') except: print(f'{cid}迁移失败') db.commit() db.close()评论数据迁移脚本# -*- coding: utf-8 -*- """ ------------------------------------------------- @ Author :Lan @ Blog :www.lanol.cn @ Date : 2021/6/29 @ Description:I'm in charge of my Code ------------------------------------------------- """ import pymysql import time HOST = "数据库HOST地址" USER = "数据库用户名" PASSWORD = "数据库密码" PORT = 数据库端口 db = pymysql.connect(HOST, USER, PASSWORD, "旧数据库名称", PORT, charset='utf8') selectSql = "select * from zbp_comment" cursor = db.cursor() cursor.execute(selectSql) source = cursor.fetchall() db.close() db = pymysql.connect(HOST, USER, PASSWORD, "新数据库名称", PORT, charset='utf8') cursor = db.cursor() for i in source: cid = i[1] created = i[10] author = i[6] authorId = i[5] ownerid = i[5] mail = i[7] url = i[8] ip = i[11] agent = i[12] text = i[9] type = 'comment' status = 'approved' parent = i[4] try: insertSql = f"Insert into typecho_comments values (NULL ,'{cid}','{created}','{author}','{authorId}','{ownerid}','{mail}','{url}'" \ f",'{ip}','{agent[:100]}','{text}','{type}','{status}','{parent}')" cursor.execute(insertSql) db.commit() except: print(f'{cid}迁移失败') db.commit() db.close()
2021年06月30日
429 阅读
1 评论
1 点赞
2021-06-11
Vue2封装axios,axios在Vue.cli中的使用
添加http.js文件在src目录下新增一个目录utils,并新增一个js文件http.js,用以实现axios的封装 编辑http.js,首先导入axios import axios from 'axios'定义Http Request公共信息,用以添加授权等 axios.interceptors.request.use( config => { let token = 'lanol' config.headers.token = token; if (config.method == 'get') { config.params.token = token } if (config.method == 'post') { config.data.token = token } return config; }, error => { return Promise.reject(err); } )封装Get方法export function get(uri, params = {}) { return new Promise((resolve, reject) => { axios.get(uri, { params: params }) .then(response => { resolve(response.data) }) .catch(err => { reject(err) }) }) }封装POST方法export function post(uri, data = {}) { return new Promise((resolve, reject) => { axios.get(uri, { params: params }) .then(response => { resolve(response.data) }) .catch(err => { reject(err) }) }) }封装patch请求export function patch(url, data = {}) { return new Promise((resolve, reject) => { axios.patch(url, data) .then(response => { resolve(response.data); }, err => { reject(err) }) }) }封装PUT请求export function put(url, data = {}) { return new Promise((resolve, reject) => { axios.put(url, data) .then(response => { resolve(response.data); }, err => { reject(err) }) }) }实现跨域const downloadUrl = url => { let iframe = document.createElement('iframe') iframe.style.display = 'none' iframe.src = url iframe.onload = function() { document.body.removeChild(iframe) } document.body.appendChild(iframe) }Main.js中引用import axios from 'axios' import {get,post} from '@/utils/http.js' Vue.prototype.$ajax = axios Vue.prototype.$post = post Vue.prototype.$get = get使用http.js<template> <div id="app"> {{Lan}} </div> </template> <script> import axios from '@/utils/http.js' export default { name: 'app', components: { }, data() { return { Lan: '' } }, mounted() { this.$get('https://v1.hitokoto.cn').then((response)=>{ this.Lan = response.hitokoto console.log(response); }) } } </script> <style> #app { font-family: 'Avenir', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style> 参考链接https://www.cnblogs.com/zhangbs/p/9681032.html
2021年06月11日
574 阅读
0 评论
0 点赞
2021-05-29
uvicorn启动fastapi使用websocket报错Unsupported upgrade request
原因:Uvicorn在新版本后[>= 0.12]有关,不会自动提供websocket实现。解决:先卸载已有版本uvicorn:pip uninstall unicorn重新安装指定版本pip install uvicorn [standard]即可正常使用。
2021年05月29日
1,004 阅读
0 评论
0 点赞
2021-05-28
微信小程序扫描二维码进入小程序指定页面并传递参数
诶,我会,我就不写,诶,我就是玩儿
2021年05月28日
604 阅读
0 评论
0 点赞
2021-05-28
python PIL/cv2/base64相互转换
PIL和cv2是python中两个常用的图像处理库,PIL一般是anaconda自带的,cv2是opencv的python版本。base64在网络传输图片的时候经常用到。PIL读取、保存图片方法from PIL import Image img = Image.open(img_path) img.save(img_path2)cv2读取、保存图片方法import cv2 img = cv2.imread(img_path) cv2.imwrite(img_path2, img)图片文件打开为base64import base64 def img_base64(img_path): with open(img_path,"rb") as f: base64_str = base64.b64encode(f.read()) return base64_str1、PIL和cv2转换PIL转cv2import cv2 from PIL import Image import numpy as np def pil_cv2(img_path): image = Image.open(img_path) img = cv2.cvtColor(np.asarray(image),cv2.COLOR_RGB2BGR) return imgcv2转PILimport cv2 from PIL import Image def cv2_pil(img_path): image = cv2.imread(img_path) image = Image.fromarray(cv2.cvtColor(image,cv2.COLOR_BGR2RGB)) return image2、PIL和base64转换##PIL转base64 import base64 from io import BytesIO def pil_base64(image): img_buffer = BytesIO() image.save(img_buffer, format='JPEG') byte_data = img_buffer.getvalue() base64_str = base64.b64encode(byte_data) return base64_strbase64转PILimport base64 from io import BytesIO from PIL import Image def base64_pil(base64_str): image = base64.b64decode(base64_str) image = BytesIO(image) image = Image.open(image) return imagecv2和base64转换import cv2def cv2_base64(image): base64_str = cv2.imencode('.jpg',image)[1].tostring() base64_str = base64.b64encode(base64_str)return base64_str base64转cv2import base64 import numpy as np import cv2def base64_cv2(base64_str): imgString = base64.b64decode(base64_str) nparr = np.fromstring(imgString,np.uint8) image = cv2.imdecode(nparr,cv2.IMREAD_COLOR) return image
2021年05月28日
507 阅读
0 评论
0 点赞
2021-05-27
Redraiment的遭遇——Python
Lee 的老家住在工业区,日耗电量非常大。今年 7 月,传来了不幸的消息,政府要在 7、8 月对该区进行拉闸限电。政府决定从 7月 1 日起停电,然后隔一天到 7 月 3 日再停电,再隔两天到 7 月 6 日停电,依次下去,每次都比上一次长一天。Lee 想知道自己到家后到底要经历多少天倒霉的停电。请编写程序帮他算一算。任务:实现停电停多久问题关键算法。注意:从键盘输入放假日期、开学日期,日期限定在 7、8 月份,且开学日期大于放假日期,然后在屏幕上输出停电天数。提示:可以用数组标记停电的日期。def td(): sm = int(input('请输入起始月份:')) sd = int(input('请输入起始天数:')) em = int(input('请输入结束月份:')) ed = int(input('请输入结束天数:')) b = [i for i in range(1, 63)] if sm == 7: b = b[sd - 1:] else: b = b[sd - 1 + 31:] if em == 7: b = b[0:ed - sd + 1] else: b = b[0:31 - sd + 1 + ed] a, c, res = 1, 1, 0 while a <= 62: a = int((c + 1) * c / 2) c += 1 if a in b: res += 1 print(a, end=',') print(f' 天数:{res}')
2021年05月27日
592 阅读
0 评论
0 点赞
1
...
21
22
23
...
65