随笔分类 -  Python常用方法

1 2 3 4 5 ··· 13 下一页

收藏了一些好的文章以及教程 Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/), 是一种面向对象的解释型计算机程序设计语言,由荷兰人Guido van Rossum于1989年发明,第一个公开发行版发行于1991年。 Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议[1] 。
企业微信「微信客服」API 接入配置总结
摘要:目前你已经成功获取 open_kfid,说明微信客服账号列表接口已经可以正常调用。 下面把 企业 ID(CorpID)、AgentID、Secret、access_token、open_kfid(你说的 kfid) 的获取方式,以及它们之间的关系统一整理一下,后续可以直接作为红绿灯领航项目的开发文档 阅读全文

posted @ 2026-10-23 17:46 星河赵 阅读(55) 评论(0) 推荐(0)

python 5 种虚拟环境创建方式
摘要:Python 创建虚拟环境主要有 5 种常见方式:venv、virtualenv、uv、conda、Poetry。 如果你主要开发 FastAPI、Flask、LangChain、LangGraph 项目,我推荐使用 venv 或 uv。 一、5 种虚拟环境创建方式 方式 特点 推荐程度 venv 阅读全文

posted @ 2026-10-08 11:19 星河赵 阅读(12) 评论(0) 推荐(0)

学习Ai LangChain&&LangGraph
摘要:LangChain 关键点 1、ChatOpenAI:模型入口 用来调用大模型,核心方法就是: result = llm.invoke("问题") 2、Message:聊天数据结构 重点记住三个: SystemMessage → 系统规则 HumanMessage → 用户问题 AIMessage 阅读全文

posted @ 2026-09-16 15:26 星河赵 阅读(8) 评论(0) 推荐(0)

Ubuntu + Nginx 使用 Let's Encrypt 生成 HTTPS 证书
摘要:适用场景: 域名已经解析到服务器公网 IP 服务器使用 Ubuntu + Nginx 例如域名: light-test.motestxing.com 1. 前置检查 先确认域名解析是否正确: ping light-test.motestxing.com 确认 80 端口可以正常访问: http:// 阅读全文

posted @ 2026-08-27 17:43 星河赵 阅读(15) 评论(0) 推荐(0)

微信支付申请相关资料
摘要:登录微信支付后台API安全 https://pay.weixin.qq.com/index.php/core/cert/api_cert#/ 获取微信支付相关参数 需要准备: 微信支付商户号:mch_id 已与商户号关联的 AppID:例如服务号 AppID API v3 密钥:32 字节,项目配置 阅读全文

posted @ 2026-08-18 14:44 星河赵 阅读(71) 评论(0) 推荐(0)

LangChain AI 客服 Agent 项目学习笔记
摘要:LangChain AI 客服 Agent 项目学习笔记 1. 项目定位 这个项目是一个面向证件照在线制作小程序的 AI 客服 Agent demo。 小程序业务包括: 用户上传照片 选择证件照规格 系统自动制作证件照 普通电子证件照免费下载 美颜、高清处理、换装、冲印纸质照片等增值服务收费 当前项 阅读全文

posted @ 2026-07-10 12:00 星河赵 阅读(49) 评论(0) 推荐(0)

在Pycharm 中使用 Python Module 方式启动 uvicorn
摘要:你的命令是: ./venv/bin/uvicorn game_test.ws_app:app --host 0.0.0.0 --port 8090 在 PyCharm 里推荐改成 module 方式: python -m uvicorn game_test.ws_app:app --host 0.0 阅读全文

posted @ 2026-03-10 15:47 星河赵 阅读(182) 评论(0) 推荐(0)

Python 项目模块导入问题解决方案
摘要:问题描述 在 Python 项目中直接运行子目录下的文件时,会出现 ModuleNotFoundError: No module named 'xxx' 错误,因为 Python 找不到项目根目录的模块。 解决方案总结 方案一:在代码中添加路径配置(推荐用于测试脚本) 在 Python 文件的 if 阅读全文

posted @ 2026-01-27 15:55 星河赵 阅读(145) 评论(0) 推荐(0)

Python -m 用法(极简版)
摘要:是什么? 按“模块名”运行代码,不是按文件路径 标准写法 python -m 包名.子包名.模块名 ❌ 不写 .py ❌ 不用 / ✅ 用 . 为什么用 -m 自动把项目根目录加入 sys.path 和 FastAPI / Gunicorn / pytest 的 import 行为一致 避免 Mod 阅读全文

posted @ 2025-12-18 09:58 星河赵 阅读(81) 评论(0) 推荐(0)

HMAC-SHA256 请求签名与验签实践(Python 可直接复用)
摘要:目标:沉淀一套“能复制即用”的签名/验签规范与代码,解决接口防篡改与防伪造。 关键规则: 待签名串:METHOD + "\n" + Content-MD5 + "\n" + URI_PATH + [ "?" + sorted_query ] Content-MD5:对“原始请求体字节”计算 MD5, 阅读全文

posted @ 2025-10-17 10:21 星河赵 阅读(1292) 评论(0) 推荐(0)

python fast api websocket 连接事例
摘要:服务端事例: # -*- coding: utf-8 -*- import asyncio import traceback import json import uuid from fastapi import FastAPI, WebSocket, WebSocketDisconnect fro 阅读全文

posted @ 2025-10-11 18:08 星河赵 阅读(60) 评论(0) 推荐(0)

python fast api 部署
摘要:python fast api 部署 1.新建gunicron_config.py # 基本配置 workers = multiprocessing.cpu_count() worker_class = "uvicorn.workers.UvicornWorker" # worker_class = 阅读全文

posted @ 2025-08-21 16:06 星河赵 阅读(64) 评论(0) 推荐(0)

python 图片缩放到指定像素
摘要:python 图片缩放到指定像素 from PIL import Image import io import base64 MAX_SIZE = 2450 def resize_image_max_side(image_data: bytes, max_side: int = MAX_SIZE) 阅读全文

posted @ 2025-06-14 11:07 星河赵 阅读(81) 评论(0) 推荐(0)

png转alpha图片
摘要:png转alpha import cv2 import os save_path = "/tmp/17527.png" img_png = cv2.imread(save_path, cv2.IMREAD_UNCHANGED) alpha = img_png[:, :, 3] os.remove(s 阅读全文

posted @ 2025-06-12 17:08 星河赵 阅读(50) 评论(0) 推荐(0)

通过auth0实现google登录和apple登录以及emal登录
摘要:客户端传 code 给后端换 token(清晰流程) [前端跳转到 Auth0 登录页面(response_type=code)] | v [用户登录后,Auth0 回调前端页面 /fe-login-callback?code=xxx] | v [前端拿到 code 后,请求你后端 API:/api 阅读全文

posted @ 2025-06-03 16:41 星河赵 阅读(383) 评论(1) 推荐(0)

python 将html 转为pdf
摘要:如果你是在 Linux (如 Ubuntu) 环境中运行,可以通过如下命令安装: sudo apt-get update sudo apt-get install -y wkhtmltopdf 🛠 安装(推荐 Python 3.7+) pip install pdfkit 🔧 如果安装失败,可能 阅读全文

posted @ 2025-05-20 15:08 星河赵 阅读(183) 评论(0) 推荐(0)

python 通过asyncio 协程来下载图片
摘要:python 通过asyncio 协程的方式来下载图片 """ 以协程的方式下载图片 """ import os import sys import asyncio import aiohttp import traceback sys.path.append(os.path.abspath(os. 阅读全文

posted @ 2025-05-19 15:31 星河赵 阅读(68) 评论(0) 推荐(0)

提取png图片为alpha图
摘要:通过opencv 提取png图片为alpha图 import cv2 img_png = cv2.imread(save_path, cv2.IMREAD_UNCHANGED) alpha = img_png[:, :, 3] os.remove(save_path) # 删除提取alpha 前的图 阅读全文

posted @ 2025-04-30 18:03 星河赵 阅读(65) 评论(0) 推荐(0)

python 爬虫淘宝天猫
摘要:python 爬虫获取淘宝天猫的图片和标题 以 Playwright + Python 为例: 扫码登录获取 cookies 的方式(推荐用 headless browser 实现) 由于linux服务器没有页面,使用 headless=False + Xvfb(虚拟显示)模拟图形界面(推荐在服务器 阅读全文

posted @ 2025-04-24 16:25 星河赵 阅读(439) 评论(0) 推荐(0)

Python 使用 EasyOCR检测图片是否有文字
摘要:检测图片是否有文字: EasyOCR 对 中文、手写字体、复杂背景 处理更好。 github 地址:https://github.com/JaidedAI/EasyOCR 安装: pip install easyocr model 相关安装包 1,模型的官方地址: https://www.jaide 阅读全文

posted @ 2025-03-24 11:34 星河赵 阅读(395) 评论(0) 推荐(0)

1 2 3 4 5 ··· 13 下一页

导航