#
Python
python 文件类型识别库 magika
magika使用 bash pip install magika python !magika **/duckdb/data python-magic使用 bash pip install python-magic mac 和Windows用户还需要额外安装libmagic fil...
Posted by spike on 2024-07-28
#
Python
python 图片左下角添加水印
python from watermark import File, Watermark, Position, apply_watermark import os from PIL import Image def add_watermark(src_img_path, watermark_path): try: 获取源图片文件名和扩展...
Posted by spike on 2024-06-04
#
Python
python库 transitions 状态机
python from transitions import Machine class Matter(object): pass lump = Matter() 状态定义 states=['solid', 'liquid', 'gas', 'plasma'] 初始化状态机 machine = Machine(model=lump, s...
Posted by spike on 2024-05-14
#
Python
python 库 box 解析json yaml
python from box import Box movie_data = {"name": "Inception", "director": "Christopher Nolan"} movie = Box(movie_data) print(movie.name) 输出: Inception Inception
Posted by spike on 2024-05-14
#
Python
使用wechat_pyrobot定时采集公众号
插件 [wechat_pyrobot 下载地址}(https://www.123pan.com/s/ihEKVv-XcWx.html) 代码 python import os import json from wechat_pyrobot.msg_plugins import MonitorBiz class MyMonitorBiz(Mon...
Posted by spike on 2024-04-28
#
Python
本地环境使用ollama千问大模型
安装ollama和千问 [ollama官网](https://ollama.com/library/qwen) 通过api调用 python import requests import json url = "http://localhost:11434/api/chat" payload = { "model": "qw...
Posted by spike on 2024-04-06
#
Python
Python nuitka 不同平台统一打包脚本
python import os import platform app_name ='douyin_auto' ico_path ='' output ='output' main ='main.py' system =platform.system) version =platform.release() if system='Windows': ...
Posted by spike on 2024-03-01
#
Python
Python ImageGrab 图像对比 监控屏幕变化
python from PIL import ImageGrab import numpy as np import time import requests Import the requests library def get_screen_region_screenshot(region): """ 获取屏幕指定区域的截图 ...
Posted by spike on 2024-02-15
#
Python
Python fastapi的缓存插件 fastapi-cache2
安装 bash pip install fastapi-cache2 or pip install "fastapi-cache2[redis]" or pip install "fastapi-cache2[memcache]" or pip install "fastapi-cache2[dynamodb]" 使用例子 ...
Posted by spike on 2024-02-15
#
Python
Python potrace 位图转矢量图
简介 使用potrace.exe可以把位图转化为svg然后上传到阿里云oss存储。 为什么要使用阿里云的oss存储呢? 因为需要转换的量实在太大了,超过200w张文件,磁盘的存储这么多文件在执行过程中会逐渐卡死,即使时使用的是ssd,故使用阿里云的oss,这样可以缓解磁盘性能引起的程序中断问题。 代码 python import sys im...