03 2025 档案

摘要:Implicit Chaining 产生原因:处理异常时,except 块中的代码抛出新的异常。 示例代码: try: 1 / 0 # 这里抛出 ZeroDivisionError except ZeroDivisionError: raise ValueError # 这里抛出 ValueErro 阅读全文
posted @ 2025-03-31 14:35 Undefined443 阅读(420) 评论(0) 推荐(0)
摘要:系统:Ubuntu 22.04 报错: $ clang++ main.cpp read.cpp:1:10: fatal error: 'fstream' file not found #include <fstream> ^~~~~~~~~ 1 error generated. 错误原因:系统安装了 阅读全文
posted @ 2025-03-27 22:53 Undefined443 阅读(342) 评论(0) 推荐(0)
摘要:指数加权平均 指数加权平均(Exponentially Weighted Averages,EWA) ,也叫做指数移动平均(Exponentially Moving Averages,EMA) 是一种用于平滑时间序列数据的技术,通过对数据点赋予不同的权重来计算平均值,其中最近的数据点被赋予更大的权重 阅读全文
posted @ 2025-03-23 16:22 Undefined443 阅读(27) 评论(0) 推荐(0)
摘要:创建一个 .pre-commit-config.yaml 文件: repos: - repo: https://github.com/psf/black rev: '22.8.0' hooks: - id: black args: - --line-length=120 - repo: https: 阅读全文
posted @ 2025-03-15 07:37 Undefined443 阅读(31) 评论(0) 推荐(0)
摘要:根据 RFC 1918 定义,以下网段被保留用于私有网络: A 类私有地址段:10.0.0.0/8(10.0.0.0 到 10.255.255.255) B 类私有地址段:172.16.0.0/12(172.16.0.0 到 172.31.255.255) C 类私有地址段:192.168.0.0/ 阅读全文
posted @ 2025-03-14 12:57 Undefined443 阅读(64) 评论(0) 推荐(0)
摘要:astral-sh/uv 安装 macOS brew install uv Linux curl -LsSf https://astral.sh/uv/install.sh | sh 安装命令补全 echo 'eval "$(uv generate-shell-completion bash)"' 阅读全文
posted @ 2025-03-14 04:20 Undefined443 阅读(442) 评论(0) 推荐(0)
摘要:main.c: #include <stdio.h> #include <unistd.h> int main() { int fd[2]; // 创建管道 if (pipe(fd) == -1) { fprintf(stderr, "pipe(fd) failed\n"); return -1; 阅读全文
posted @ 2025-03-13 04:34 Undefined443 阅读(19) 评论(0) 推荐(0)
摘要:tasks.json tasks.json 用于设置构建指令。 Python { "version": "2.0.0", "tasks": [ { "label": "main", "type": "shell", "command": "python", "args": [ "main.py", 阅读全文
posted @ 2025-03-12 01:28 Undefined443 阅读(136) 评论(0) 推荐(0)
摘要:pip freeze | cut -d "=" -f 1 | xargs -n 1 pip uninstall -y 阅读全文
posted @ 2025-03-11 23:26 Undefined443 阅读(34) 评论(0) 推荐(0)
摘要:在使用 pip 卸载 Python 包时出现如下错误: pip uninstall xkit Found existing installation: xkit 0.0.0 Not uninstalling xkit at /usr/lib/python3/dist-packages, outsid 阅读全文
posted @ 2025-03-10 21:27 Undefined443 阅读(235) 评论(0) 推荐(0)
摘要:PyTest 是一个流行的 Python 测试框架,简单易用且功能强大,适用于单元测试和功能测试。 安装 pip install pytest 编写测试代码 PyTest 会自动发现以 test_ 开头的函数或以 Test 开头的类方法。所以,你需要按照这种命名约定来编写测试。 示例: 目录布局: 阅读全文
posted @ 2025-03-09 17:43 Undefined443 阅读(96) 评论(0) 推荐(0)
摘要:单元文件类型: .service:定义系统服务 .socket:定义套接字激活服务 .device:定义硬件设备 .mount 和 .automount:定义文件系统的挂载点 .timer:定义类似 cron 的定时任务 .target:将一组服务和其他单元逻辑地组合在一起,以达到某种系统状态(类似 阅读全文
posted @ 2025-03-07 21:45 Undefined443 阅读(101) 评论(0) 推荐(0)
摘要:编译并使用动态链接库 创建共享库源文件 math.c: int add(int a, int b) { return a + b; } 创建共享库头文件 math.h: int add(int a, int b); 编译动态链接库: gcc -shared -fPIC math.c -o libma 阅读全文
posted @ 2025-03-05 02:54 Undefined443 阅读(43) 评论(0) 推荐(0)
摘要:问题描述 我有 3 块显卡: + + | NVIDIA-SMI 550.127.08 Driver Version: 550.127.08 CUDA Version: 12.4 | | + + + | GPU Name Persistence-M | Bus-Id Disp.A | Volatile 阅读全文
posted @ 2025-03-01 21:48 Undefined443 阅读(254) 评论(0) 推荐(0)
摘要:history 对于 Zsh 用户,可以使用 fc 命令来搜索历史记录,它是 history 命令的增强版本: fc -l 1 这里 -l 选项表示列出历史条目,1 是从历史记录的第一条命令开始搜索。 最后,如果你在 Zsh 中启用了增强的历史搜索功能,也可以直接通过按下特定的快捷键(如 Ctrl 阅读全文
posted @ 2025-03-01 21:02 Undefined443 阅读(145) 评论(0) 推荐(0)
摘要:格式: echo -e "\033[控制代码m输出文本" \033[控制代码m 是转义序列,其中 \033[ 是转义起始符,m 是转义终止符。 \033 对应 ASCII 码表的 ESC,可以用 \e 或 \E 代替。 控制代码是一系列由 ; 分隔的数字。 文本样式控制代码: 0:清除所有样式 1: 阅读全文
posted @ 2025-03-01 21:00 Undefined443 阅读(58) 评论(0) 推荐(0)
摘要:w 可以看到当前登录用户、登录位置,以及他们正在执行的命令。 $ w 09:43:34 up 1 day, 7:34, 10 users, load average: 3.77, 2.59, 2.08 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT lx pts/0 阅读全文
posted @ 2025-03-01 17:57 Undefined443 阅读(47) 评论(0) 推荐(0)