文章分类 -  1. web 开发 / 1. 后端 / 1. Python

摘要:1. 模块下载 pip install opencv-python -i https://mirrors.aliyun.com/pypi/simple 2. 加普通图片 import cv2 # 设置视频文件路径和水印图片路径 video_path = 'test.mp4' watermark_pa 阅读全文
posted @ 2024-12-11 15:03 河图s 阅读(80) 评论(0) 推荐(0)
摘要:1. XAdmin 9. 其他 Django 集成Vue页面 Python 操作Excel Django-Admin 集成富文本编辑器 Django 支付宝支付 Django 微信支付 阅读全文
posted @ 2024-10-22 20:13 河图s 阅读(11) 评论(0) 推荐(0)
摘要:1. 地图边界数据集 使用 static/map/china.json 即可 2. 模块下载 pip install shapely 3. 代码实现 from shapely.geometry import Point, Polygon import json def point_of_which_ 阅读全文
posted @ 2024-10-10 16:14 河图s 阅读(143) 评论(0) 推荐(0)
摘要:1. 模块 pip install pillow-avif-plugin Pillow -i https://mirrors.aliyun.com/pypi/simple/ 2. 实现 import pillow_avif #注意一定要引入pillow_avif否则会抛异常'cannot ident 阅读全文
posted @ 2024-05-16 17:02 河图s 阅读(316) 评论(0) 推荐(0)
摘要:1. UTC时间 1.1 转Datetime对象 start_time = "2024-03-22T15:37:37.859143Z" datetime.datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%S.%fZ') 1.2 去掉毫秒级 2024-03- 阅读全文
posted @ 2024-03-22 16:43 河图s 阅读(41) 评论(0) 推荐(0)
摘要:1. 数值转天时分 # 时间格式转换 def time_format_conversion(seconds): """ 用于将运行时间等两个时间之间的时间戳之差(单位秒)转换成XX小时XX分钟XX秒的格式 """ onedays = 24 * 3600 days, other = divmod(se 阅读全文
posted @ 2024-03-22 14:53 河图s 阅读(32) 评论(0) 推荐(0)
摘要:1. 操作系统 1.1 判断当前操作系统 import sys if sys.platform == "win32": os.rename(cu_path, file_path) else: os.system(f"mv {cu_path} {file_path}") 2. 文件夹 2.1 查询文件 阅读全文
posted @ 2024-01-02 16:24 河图s 阅读(22) 评论(0) 推荐(0)
摘要:1. 读取Excel import logging import pandas as pd logger = logging.getLogger('django') RoomNameIndex = 0 HomeOwnerNameIndex = 1 IdNumberIndex = 2 all_dict 阅读全文
posted @ 2023-12-26 17:47 河图s 阅读(27) 评论(0) 推荐(0)
摘要:1. 模块下载 # 最好是3.0.5 不然启动不了asgi pip install channels==3.0.5 阅读全文
posted @ 2023-12-19 16:12 河图s 阅读(17) 评论(0) 推荐(0)
摘要:1. 判断当天是当年的第多少周 import datetime def get_week(date_str): date_time = datetime.datetime.strptime(date_str, '%Y-%m-%d') first_day = datetime.datetime(dat 阅读全文
posted @ 2023-11-17 16:39 河图s 阅读(57) 评论(0) 推荐(0)
摘要:1. 基础 7. 内置模块 Python time Python datetime 8. 常用自定义函数 Python 常用自定义函数 9. OS 交互 Python 执行OS命令 2. Web框架 2.1 Django 1. Django基础 2. 内置组件 Django ORM Django A 阅读全文
posted @ 2023-10-11 11:27 河图s 阅读(23) 评论(0) 推荐(0)
摘要:1. 基础配置 1.1 本地时区 settings.py LANGUAGE_CODE = 'zh-hans' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False 1.2 静态目录 settings.py 阅读全文
posted @ 2023-06-29 16:01 河图s 阅读(53) 评论(0) 推荐(0)
摘要:[TOC] ## 安装 ``` # 同步代码安装 pip install elasticsearch # 异步代码安装 python -m pip install elasticsearch[async] ``` ## index ### 创建index 创建一个名为news的索引 ``` from 阅读全文
posted @ 2021-08-03 15:37 河图s 阅读(80) 评论(0) 推荐(0)
摘要:[TOC] ## Python redis 使用介绍 ### *分类* [编程技术](https://www.runoob.com/w3cnote_genre/code) 本章节我们将为大家介绍 Python 如何操作 redis,redis 是一个 Key-Value 数据库,Value 支持 s 阅读全文
posted @ 2021-07-05 17:46 河图s 阅读(29) 评论(0) 推荐(0)
摘要:[TOC] # pymysql ## 下载安装 ```python pip3 install pymysql ``` ## 执行 sql 语句 ```python 1. 用字符串拼接的方式避免sql注入 import pymysql # 创建链接 conn = pymysql.Connection( 阅读全文
posted @ 2021-07-05 17:45 河图s 阅读(32) 评论(0) 推荐(0)
摘要:[TOC] # 理论 WebSocket协议是基于TCP的一种新的协议。WebSocket最初在HTML5规范中被引用为TCP连接,作为基于TCP的套接字API的占位符。它实现了浏览器与服务器全双工(full-duplex)通信。其本质是保持TCP连接,在浏览器和服务端通过Socket进行通信。 本 阅读全文
posted @ 2021-07-05 17:43 河图s 阅读(26) 评论(0) 推荐(0)