摘要:
在try之前、加上# noinspection PyBroadException # noinspection PyBroadException try: ... except: ... 阅读全文
摘要:
# 使用list() bytesDate = '源数据'.encode() print(bytesDate, list(bytesDate)) 阅读全文
摘要:
import urllib3 # 禁用警告 urllib3.disable_warnings() # urllib3 不验证ssl _pool_params = dict(cert_reqs='CERT_NONE', assert_hostname=False) url = 'https://www 阅读全文
摘要:
安装 pip install pillow 添加文字水印 from PIL import Image, ImageDraw, ImageFont img_name = '1.jpg' text = '博客园 @三个零' img = Image.open(img_name) draw = ImageD 阅读全文
摘要:
安装 pip install docx2pdf 使用 from docx2pdf import convert # doc 文件 需要先转为 docx 文件(一般情况下、直接修改后缀名、不会对原文件有影响) inputFile = '1.docx' # 要转换的文件:已存在 outputFile = 阅读全文
摘要:
pprint 官方文档 https://docs.python.org/3/library/pprint.html from pprint import pprint data_json = {'a': "923c550d262a468237e34777b6279fdf", 'b': "a3c1f8 阅读全文
摘要:
""" 将 各种格式的 cookie 转为 字典格式 """ def cookie_factory(ck_str=None): cookie_dict = {} # 从浏览器 抓包 复制过来的 cookie 字符串 if ck_str: for cookie in ck_str.split(';') 阅读全文
摘要:
chrome 插件 XPath Helper :使用xpath匹配的时候,数据更直观 Tampermonkey(油猴):脚本管理器 AdGuard :广告拦截器,可以自定义拦截页面,超级好用 FeHelper(前端助手):网页中的 JSON 自动格式化显示 MONKNOW:新标签页 vscode 插 阅读全文
摘要:
播放器 完美解码 :potplay这个号称最强的本地视频播放器 https://potplayer.daum.net/ 屏幕操作 Snipaste :截图 + 贴图 + 取色 https://zh.snipaste.com/ ZoomIt :屏幕划线、点 https://docs.microsoft 阅读全文
摘要:
通过 Traceback 能得知运行异常的位置、原因 当程序没有捕获异常、运行异常时 会自动调用 Traceback 进行异常回溯 捕获异常 当程序捕获异常时 不会自动调用 Traceback 进行异常回溯 def run(): try: print('Before') print(1 / 0) p 阅读全文
摘要:
将当前环境中已安装的三方库及对应版本 输出到文本中 pip freeze > requirements.txt 卸载当前环境中所有安装的库 pip uninstall -r requirements.txt -y 安装文本中 对应版本的所有三方库 pip install -r requirement 阅读全文
摘要:
安装 pip install scrapy 导入 from scrapy.selector import Selector 待提取文本 content = """ <table class="tab"> <tr class="cdf"> 1<a>tr下的第一个a标签</a>2 3<td class= 阅读全文
摘要:
方法一 先按 Ctrl + F8:Deactivate breakpoints 禁用所有断点 再按 F8:Resume script execution 恢复脚本执行 这种情况下,自己添加的断点也会被禁用 方法二 在 debugger 所在行的行号(数字)上,右键选择Add conditional 阅读全文
摘要:
关闭不安全请求警告 import urllib3 urllib3.disable_warnings() import requests import urllib3 urllib3.disable_warnings() response = requests.get('https://www.bai 阅读全文
摘要:
导入 import pickle 转换 data = [{'title': 't1', 'url': 'one'}, {'title': 't2', 'url': 'two'}] data_dumps = pickle.dumps(data) print(type(data_dumps)) # <c 阅读全文
摘要:
Python 使用正则 清除字符串中除了 <sub>...</sub> 和 <sup>...</sup> 以外的所有 html 标签 指定标签内无其它标签 import re def sub_replace(match_obj): # print(type(match_obj), match_obj 阅读全文
摘要:
IP 查看 http://ip111.cn http://httpbin.org/get http://test.abuyun.com https://ip.cn https://ip.tool.lu https://ipapi.co/json https://www.ip138.com https 阅读全文
摘要:
Headers General Request URL:请求链接 Request Method:请求方式 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Methods Status Code:状态码(可自定义) https://www.runoo 阅读全文
摘要:
当队列为空时,执行get(),不会报异常 会进入阻塞状态,直到队列中有东西可取为止 from queue import Queue taskQueue = Queue() taskQueue.put('queue task 1') print(f'队列长度:{taskQueue.qsize()}') 阅读全文
摘要:
请求 视频地址 和 M3U8 地址 的时候,http 请求中会带上自定义的请求头 // 全局拦截器 videojs.Vhs.xhr.beforeRequest = function (options: any) { let headers = options.headers || {}; heade 阅读全文
摘要:
import os # os.path.split 分割路径 path1 = r'e:\tool\read.txt' print(os.path.split(path1)) # ('e:\\tool', 'read.txt') print(os.path.splitext(path1)) # ('e 阅读全文
摘要:
单进程单线程 import time def production(): """ 间隔一秒,模拟一秒生产一个任务,生产10个任务 :return: 生产完毕,返回需要消费的任务 """ _tasks = 0 while _tasks < 10: time.sleep(1) _tasks += 1 p 阅读全文
摘要:
Module 模块 export:导出模块 point.ts 文件的内容(导出) interface IPoint{ num:number printNum:() => void; } // 关键字 export 导出模块 export class Point implements IPoint{ 阅读全文
摘要:
Access Modifier 访问修饰符 public:默认都为公开的 public interface IPoint{ x:number; y:number; drawoPoint:() => void; getDistances:(p:IPoint) => number; } class Po 阅读全文
摘要:
Generics 泛型 相当于一个模板,往里面填充什么类型,就是什么类型的数据 // 参数前用 <> 声明泛型 let lastInArray = <T>(arr: T[]) => { return arr[arr.length -1]; } const l1 = lastInArray([1,2, 阅读全文
摘要:
object 对象类型 不是 key - value 的形式 而是 key - type 的形式 let person = { age: 18, name: 'three zeros' } // 赋值类型与定义时的类型不同时,会报错 person.age = '22' // 使用不存在的属性,会报错 阅读全文
摘要:
声明变量的关键字 let const var(官方不推荐再继续使用) TypeScript 的类型 基础类型 number string boolean array null undefined object tuple enum void never any 高级类型(部分) union 组合类型 阅读全文
摘要:
TypeScript 是 JavaScript 的超集 TypeScript 无法直接在浏览器环境中运行 安装 需要 nodejs 环境 npm install -g typescript 将 ts 编译为 js tsc fileName.ts TypeScript 工作流 编写完 ts 将 ts 阅读全文
摘要:
快速移动(normal 模式下) 上下左右 h :左 j :下 k :上 l : 右 单词间移动(word :以非空白符分割的单词,WORD :以空白符分割的单词) w/W :移到下一个 word/WORD 开头 e/E :移到下一个 word/WORD 结尾 b/B :回到上一个 word/WOR 阅读全文
摘要:
进入 vim vim 文件名 vim直接编辑一个文件,如果是已经存在的文件,则是打开文件,如果是没有的文件,就会新建文件 进入 vim 默认是 normal 模式 该模式下可以进行各种命令操作和移动 不能直接编辑内容,需要进入 insert(编辑)模式才能编辑 大部分情况是在浏览,而不是编辑,所以 阅读全文
摘要:
import platform plat = platform.system().lower() if plat == 'windows': print('windows系统') elif plat == 'linux': print('linux系统') 阅读全文
摘要:
查看crontab运行状态 service crond status crontab 的默认执行路径为:当前用户的根路径 所有命令需要写成绝对路径形式,如: /usr/local/bin/docker crontab 命令常用选项及功能 -u :用来设定某个用户的 crontab 服务 -e :编辑 阅读全文
摘要:
在 Windows 上似乎是 EventLoopPolicy 的问题,使用此代码段来解决它 asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(main()) 阅读全文
摘要:
爬虫随机ua、直接使用 import random def random_ua(): ua = [ 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.0.4506. 阅读全文
摘要:
浏览器地址栏键入URL后发生了什么 浏览器构建请求行:GET / HTTP/1.0(1.1 2.0 3.0) 查找强缓存(若命中则直接使用) HTTP/1.1中使用的是Cache-Control 浏览器向 DNS 服务器请求解析该 URL 中的域名所对应的 IP 地址 解析出 IP 地址后,根据该 阅读全文
摘要:
sys.argv 一个从程序外部获取参数的桥梁 参数是从程序外部输入的 而非代码本身的什么地方 类型为List 用法 sys.argv[0]表示代码本身文件路径 从外部来运行程序并给出参数 import sys try: print(type(sys.argv), sys.argv) print(' 阅读全文
摘要:
执行worker celery -A celery_app worker -l INFO 报错not enough values to unpack (expected 3, got 0) win10上运行celery4+版本会出现这个问题 解决方法,安装eventlet pip install e 阅读全文
摘要:
pyinstrument会把代码里运行耗时的部分给你找出来 使用 pip install pyinstrument import time from pyinstrument import Profiler def sleep_time(): time.sleep(2) print('end') p 阅读全文
摘要:
###requests stream=True import time import requests download_url = '' start_time = time.time() file_name = 'video.mp4' # 文件名称 # 以流形式下载文件 result = requ 阅读全文
摘要:
import time start_time = time.time() # 内容总大小 content_size = 100 # 进度条字符 char_str = '>' # 进度条字符长度 char_long = 50 for size in range(content_size + 1): # 阅读全文