随笔分类 -  Python

Python笔记本
摘要:如果对安全性要求不高,可以选择直接将py文件,打包成exe即可,解压出来的是pyc文件,pyc文件还原成源码,也是有一定复杂度的,相对而言也是有一定的安全性的 在源文件同级目录下创建build文件 buidl_pyd.py # -*- ecoding: utf-8 -*- # @ModuleName 阅读全文
posted @ 2022-11-12 16:56 darling331 阅读(2950) 评论(0) 推荐(0)
摘要:from loguru import logger logger.add('普通日志.log', filter=lambda x: '[普通]' in x['message']) logger.add('警告日志.log', filter=lambda x: '[需要注意]' in x['messa 阅读全文
posted @ 2022-11-12 00:12 darling331 阅读(264) 评论(0) 推荐(0)
摘要:apscheduler定时任务报错skipped: maximum number of running instances reached (1) 原因是默认max_instances最大定时任务是1个,可以通过在add_job中调max_instances增加数量。 scheduler.add_j 阅读全文
posted @ 2022-11-11 23:24 darling331 阅读(584) 评论(0) 推荐(1)
摘要:直接将元组转为列表 tup = (21, 19, 11, 46, 18) print(tup) lt = list(tup) print(lt) 输出 (21, 19, 11, 46, 18) [21, 19, 11, 46, 18] 将元组列表转为列表 # List of tuple initia 阅读全文
posted @ 2022-11-10 13:54 darling331 阅读(355) 评论(0) 推荐(0)
摘要:import pymysql from loguru import logger from pymysql import converters, FIELD_TYPE conv = converters.conversions conv[FIELD_TYPE.NEWDECIMAL] = float 阅读全文
posted @ 2022-09-24 01:03 darling331 阅读(488) 评论(0) 推荐(0)
摘要:前言 一个http请求包括三个部分,为别为请求行,请求报头,消息主体,类似以下这样: 请求行 请求报头 消息主体 HTTP协议规定post提交的数据必须放在消息主体中,但是协议并没有规定必须使用什么编码方式。 服务端通过是根据请求头中的Content-Type字段来获知请求中的消息主体是用何种方式进 阅读全文
posted @ 2022-08-30 17:46 darling331 阅读(1514) 评论(0) 推荐(0)
摘要:# 对浮点数,保留小数点后几位 print('{:0.3f}'.format(50.5 / 220.5)) # print 格式化字符串 num = int(input('请输入一个十进制的整数:')) # 将str 转为int类型 print(num, '的二进制数为:', bin(num)) # 阅读全文
posted @ 2022-08-21 17:52 darling331 阅读(616) 评论(0) 推荐(0)
摘要:1,python 解释器版本3.10以上可以使用如下 def dar(darling): match darling: case '400': print(400) case '401': print(401) case _: print(404) if __name__ == '__main__' 阅读全文
posted @ 2022-08-21 12:22 darling331 阅读(66) 评论(0) 推荐(0)
摘要:判断输入的字符类型 str=input('请输入字符') # 为True表示输入的所有字符都是数字,否则,不是全部为数字str为字符串 str.isdigit() #所有字符都是数字 str.isalnum() #所有字符都是数字或者字母 str.isalpha() #所有字符都是字母 str.is 阅读全文
posted @ 2022-08-20 22:06 darling331 阅读(621) 评论(0) 推荐(0)
摘要:import pymysql def client_database_dic(sql): print('数据库:', sql) # 打开数据库连接 db = pymysql.connect(host="127.0.0.1", user="root", password="123", db="orde 阅读全文
posted @ 2022-08-11 15:22 darling331 阅读(191) 评论(0) 推荐(0)
摘要:import datetime # 时间格式转换 ## 字符串格式转为时间格式 a = '2022-08-01 14:32:47' b = datetime.datetime.strptime(a, "%Y-%m-%d %H:%M:%S") print(b, type(b)) ## 时间格式转为字符 阅读全文
posted @ 2022-08-10 16:54 darling331 阅读(700) 评论(0) 推荐(0)
摘要:header = { 'Content-Type': 'application/json;charset=UTF-8' } body = {'un': 'dafdas', 'pw': 'fasdasfa'} response = requests.post('http://www.safa.com/ 阅读全文
posted @ 2022-07-28 18:42 darling331 阅读(933) 评论(0) 推荐(0)
摘要:# -*- ecoding: utf-8 -*- # @ModuleName: test # @Funcation: # @Author: darling # @Time: 2022-07-28 15:29 import datetime import math import os import r 阅读全文
posted @ 2022-07-28 17:51 darling331 阅读(155) 评论(0) 推荐(0)
摘要:# -*- ecoding: utf-8 -*- # @ModuleName: test # @Funcation: # @Author: darling # @Time: 2022-07-28 15:29 import datetime import os import re import sys 阅读全文
posted @ 2022-07-28 16:43 darling331 阅读(247) 评论(0) 推荐(0)
摘要:背景,表格创建时,直接把表格清空,防止历史数据进行干扰新的数据写入 import openpyxl # 保存Excel def saveExcel(codes): sheet_method(['Sheet2']) data = openpyxl.load_workbook("./source_fil 阅读全文
posted @ 2022-06-24 20:51 darling331 阅读(866) 评论(0) 推荐(0)
摘要:使用 gunicorn -w 4 -b 0.0.0.0:8080 main:app 运行时,报错 TypeError: __call__() missing 1 required positional argument: 'send' from fastapi import FastAPI app 阅读全文
posted @ 2022-06-13 18:22 darling331 阅读(1462) 评论(0) 推荐(0)
摘要:python 使用uvicorn运行时报错module 'asyncio' has no attribute 'run' 很大可能是python的版本太低了 因为python3.7 及以后才支持run方法 或者是看一下你的项目文件里是不是命名了一个asyncio.py的文件,和运行的文件冲突了 阅读全文
posted @ 2022-06-13 18:15 darling331 阅读(166) 评论(0) 推荐(0)
摘要:进行fastApi开发时,发现源码swagger静态资源访问不到,可能是网址出现了问题宕机了,我们可以有以下几种方式进行处理 源码的请求位置fastapi.openapi.docs.py get_swagger_ui_html https://cdn.jsdelivr.net/npm/swagger 阅读全文
posted @ 2022-06-06 16:19 darling331 阅读(2982) 评论(1) 推荐(1)
摘要:详细代码 # -*- ecoding: utf-8 -*- # @ModuleName: test002 # @Function: # @Author: darling # @Time: 2022-06-01 13:46 import os import re import sys import t 阅读全文
posted @ 2022-06-01 01:59 darling331 阅读(635) 评论(0) 推荐(0)
摘要:原理说明 可以代码执行windows按键,然后调用微信程序的快捷键,然后进行发送相关消息,不失于一个批处理程序 ###扩展 可以对程序里面的一些数据进行维护后变更,比如需要批量发送的微信彭勇,用户名,需要发送的内容,可以用表格进行维护后,执行程序取值发送 import time import pya 阅读全文
posted @ 2022-05-25 13:44 darling331 阅读(311) 评论(0) 推荐(0)