上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页
摘要: // Distinct 函数用于对输入的切片进行去重,支持整型、浮点型和字符串类型func Distinct[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | floa 阅读全文
posted @ 2025-03-28 11:02 CJTARRR 阅读(44) 评论(0) 推荐(0)
摘要: import asynciofrom inspect import iscoroutinefunctionfrom typing import Any, Awaitable, List​​class CoroutinePool: def __init__(self, max_size: int): 阅读全文
posted @ 2025-03-13 15:28 CJTARRR 阅读(15) 评论(0) 推荐(0)
摘要: import asyncio class AsyncReadWriteLock: def __init__(self): self._readers = 0 self._writers_waiting = 0 self._writer_active = False self._lock = asyn 阅读全文
posted @ 2025-03-13 15:07 CJTARRR 阅读(33) 评论(0) 推荐(0)
摘要: 背景 python利用多核就需要开启多进程,如果多进程之间需要共享数据又不希望引入第三方的服务,就需要使用共享内存。 multiprocessing.shared_memory python 3.8之后,python内置的multiprocessing库提供了一种新的共享内存方式,shared_me 阅读全文
posted @ 2025-03-13 09:45 CJTARRR 阅读(908) 评论(0) 推荐(0)
摘要: 安装 pip install "redis[hiredis]" 检查是否启用hiredis import redisimport redis.connectionfrom redis.connection import ConnectionPoolfrom redis.utils import HI 阅读全文
posted @ 2025-03-12 16:23 CJTARRR 阅读(64) 评论(0) 推荐(0)
摘要: import re options = "i" regex_pattern = re.escape(字符串) query = {"$regex": regex_pattern, "$options": options} 结果 = 集合.find(query) # 这里用re.escape套一下字符串 阅读全文
posted @ 2025-03-12 09:33 CJTARRR 阅读(44) 评论(0) 推荐(0)
摘要: 1.在fastapi的中间件中,如果不做处理直接抛出HttpException,框架是不会捕获并处理成响应的,这时客户端看到的就是500 Internal Server Error。 2.为了能在中间件中直接抛出异常,方便写代码,需要自己添加一个中间件来对所有中间件的异常做处理。该中间件代码如下: 阅读全文
posted @ 2025-03-07 09:50 CJTARRR 阅读(126) 评论(0) 推荐(0)
摘要: 设置 => 代码片段 => 上方输入框输入"python" => 找到python.json => 在原本的json中添加一下内容: "Print to console": { "prefix": "main", "body": [ "if __name__ == '__main__':", ], 阅读全文
posted @ 2025-02-12 11:39 CJTARRR 阅读(93) 评论(0) 推荐(0)
摘要: 数据格式: data参数通常用于发送application/x-www-form-urlencoded格式的数据。这意味着数据会被编码为键值对,类似于表单提交的数据。 json参数用于发送application/json格式的数据。这意味着数据会被序列化为JSON字符串。 自动编码: 当使用data 阅读全文
posted @ 2024-12-18 10:38 CJTARRR 阅读(169) 评论(0) 推荐(0)
摘要: ffmpeg -i {ts文件路径} -c copy -map 0:v -map 0:a -bsf:a aac_adtstoasc {目标mp4文件路径} 阅读全文
posted @ 2024-12-12 11:34 CJTARRR 阅读(124) 评论(0) 推荐(0)
摘要: # 创建文件夹mkdir test# 进入文件夹cd test# git初始化git init# 暂存所有内容git add .# 提交内容git commit -m "first commit"# 设置分支名git branch -m main# 挂载本地分支到线上分支git remote add 阅读全文
posted @ 2024-09-05 09:48 CJTARRR 阅读(9) 评论(0) 推荐(0)
摘要: npm config set registry https://registry.npmmirror.com/ 阅读全文
posted @ 2024-08-18 14:28 CJTARRR 阅读(156) 评论(0) 推荐(1)
摘要: 以eslint举例: 首先直接通过npm安装,会终端会报错,包含下面这行信息: sudo chown -R 501:20 "/Users/xxxxxx/.npm" 复制并运行这段信息。 再次执行安装命令,如果还是遇到一长串报错,需要按下面的命令安装: sudo npm install -g esli 阅读全文
posted @ 2024-08-12 15:11 CJTARRR 阅读(164) 评论(0) 推荐(0)
摘要: 1、GPL ( GNU General Public License ) 商业软件不能使用GPL协议的代码。 2、LGPL ( GNU Library or “Lesser” General Public License ) 商业软件可以使用,但不能修改LGPL协议的代码。3、Apache Lice 阅读全文
posted @ 2024-08-08 09:40 CJTARRR 阅读(45) 评论(0) 推荐(0)
摘要: If-Modified-Since # 如果响应头中有Last-Modified参数下次请求的时候,请求头带上If-Modified-Since参数,参数值是Last-Modified的值。如果目标内容没有改变,则响应状态码为304, 改变了则为200。 If-None-Match # 如果响应头中 阅读全文
posted @ 2024-08-06 13:49 CJTARRR 阅读(13) 评论(0) 推荐(0)
摘要: yaml配置文件 host: localhost:3306user: rootpwd: 112233dbname: 1 安装yaml读取工具 go get gopkg.in/yaml.v2 从yaml文件读取配置 package main​import ( "fmt" "gopkg.in/yaml. 阅读全文
posted @ 2024-07-16 16:17 CJTARRR 阅读(149) 评论(0) 推荐(0)
摘要: 基本类型注释 # 变量名后面用 ":" 表示类型注释string_val :str = ""int_val :int = 0float_val :float = 0.0dic_val :dict = dict()list_val :list = list()tuple_val :tuple = tu 阅读全文
posted @ 2024-07-15 09:57 CJTARRR 阅读(63) 评论(0) 推荐(0)
摘要: 打开goland设置,找到图中框住的选项,勾上即可。 如果不勾上,goland终端里面是无法修改go env的。 阅读全文
posted @ 2024-07-06 23:31 CJTARRR 阅读(243) 评论(0) 推荐(0)
摘要: 读文件方式一 // 方式一,以字节为单位读文件package main​import ( "fmt" "io" "os")​func main() {​ // 获得文件句柄, 只读权限 f, err := os.Open("文件路径") if err != nil { fmt.Println("文件 阅读全文
posted @ 2024-05-30 11:08 CJTARRR 阅读(115) 评论(0) 推荐(0)
摘要: 介绍 python中的"类"也是对象,加载"类"也有创建对象的过程。 用于创建"类"对象的,就是元类。 元类可以自定义。 元类示例 class DemoMeta(type): def __new__(cls, name, bases, attrs): cls_instance = super()._ 阅读全文
posted @ 2024-05-27 16:46 CJTARRR 阅读(15) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页