随笔分类 -  python

1 2 3 4 5 ··· 9 下一页
关于python
摘要:格式化长数据 json.dumps(需要格式的数据, ensure_ascii=False) # 确保中文不会被转义 阅读全文
posted @ 2025-02-07 15:32 __username 阅读(254) 评论(0) 推荐(0)
摘要:import os # 获取完整路径 file_path = os.path.abspath(__file__) # 获取文件名(带扩展) file_name = os.path.basename(__file__) # 获取文件名(不带扩展) file_name_no_ext = os.path. 阅读全文
posted @ 2025-02-02 09:03 __username 阅读(248) 评论(0) 推荐(0)
摘要:from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 as Cipher_pkcs1_v1_5 import base64 def rsa_encrypt(publickey, data): """校验RSA加密 阅读全文
posted @ 2025-01-13 00:01 __username 阅读(300) 评论(0) 推荐(0)
摘要:pop() 和 remove() 在 Python 中都有移除元素的功能,但它们的使用场景和行为不同: 1. 功能对比 特性 pop() remove() 返回值 移除的元素(或值) 无(直接移除,不返回值) 目标 按索引(列表)或键(字典),或任意元素(集合) 按值移除元素 适用数据类型 列表、字 阅读全文
posted @ 2024-11-19 07:59 __username 阅读(112) 评论(0) 推荐(0)
摘要:def lo_stat(msg=None): print(f"{msg} 启动") def lo_end(msg=None): print(f"{msg} 结束") def decorator(func): def wrapper(): # print("在函数执行之前做点事") lo_stat(f 阅读全文
posted @ 2024-11-18 11:08 __username 阅读(7) 评论(0) 推荐(0)
摘要:any 在 Python 中,any 是一个内置函数,用于判断可迭代对象(如列表、元组、集合等)中是否至少有一个元素为 True。它返回一个布尔值。 语法: any(iterable) 参数: iterable:任何可迭代对象,例如列表、元组、集合、生成器等。 返回值: True:如果 iterab 阅读全文
posted @ 2024-11-18 10:26 __username 阅读(106) 评论(0) 推荐(0)
摘要:win系统上正常, ubuntu报错 如下报错: 解决 Linux环境是英文 browser.new_context(locale="zh-CN") 阅读全文
posted @ 2024-11-16 14:07 __username 阅读(459) 评论(0) 推荐(0)
摘要:假设有一个简单的 Python 文件 my_module.py,希望将它编译为 .pyd 文件,以保护代码。 1. 安装 Cython 首先确保安装了 Cython: pip install cython 2. 创建 Python 文件 假设有以下 Python 文件 my_module.py: d 阅读全文
posted @ 2024-11-13 17:19 __username 阅读(570) 评论(0) 推荐(0)
摘要:dataclass 在 Python 中,dataclass 是一种简化创建数据类的方式,提供了自动生成的初始化方法 (__init__)、表示方法 (__repr__)、比较方法 (__eq__) 等。dataclass 可以减少手动编写这些方法的繁琐代码。下面是 dataclass 的一些基本用 阅读全文
posted @ 2024-11-13 10:19 __username 阅读(181) 评论(0) 推荐(0)
摘要:config.ini文件 [config] username = 2024222222 password = 123456 time = 202320241 num1 = 1 id1 = 018819 num2 = 1 id_1 = 018818 读取配置文件 def read_ini(): fil 阅读全文
posted @ 2024-11-10 10:32 __username 阅读(32) 评论(0) 推荐(0)
摘要:方法一: 缺点:本地,使用fd/req/sunny 抓不到包 session = requests.session() session.trust_env = False 方法二: verify=False , 本地, 使用fd/req/sunny 可以抓到包 response = requests 阅读全文
posted @ 2024-11-04 13:07 __username 阅读(104) 评论(0) 推荐(0)
摘要:场景 # main.py 部分代码 def _run_login_script(self): import subprocess # 定义 tools 目录下 login.py 脚本的路径 script_path = os.path.join(os.getcwd(), "tools", "login 阅读全文
posted @ 2024-11-04 01:47 __username 阅读(21) 评论(0) 推荐(0)
摘要:如图 解决 解决方法 安装必要的系统依赖: uwsgi 需要一些构建依赖项,这些依赖项可能默认没有安装。可以通过包管理器安装它们: 执行以下命令来安装所需的包: sudo apt-get update sudo apt-get install python3-dev build-essential 阅读全文
posted @ 2024-10-16 23:58 __username 阅读(187) 评论(0) 推荐(0)
摘要:步骤 pip install playwright playwright install playwright install-deps 若弹出这个 参考:https://www.cnblogs.com/code3/p/18458533 解决 tip 但是貌似有2s的延迟。。 阅读全文
posted @ 2024-10-12 10:46 __username 阅读(135) 评论(0) 推荐(0)
摘要:playwright自动登录获取cookie/ck有些登录逆向起来比较麻烦,就用了自动化 import time import json import random from playwright.sync_api import Playwright, sync_playwright, expect # https://xxxx.edu.cn/ap 阅读全文
posted @ 2024-10-11 16:42 __username 阅读(498) 评论(0) 推荐(0)
摘要:import datetime delta_day = 1 day = datetime.date.today() + datetime.timedelta(days=0+delta_day) print(day) # output:2024-10-08 阅读全文
posted @ 2024-10-07 19:40 __username 阅读(15) 评论(0) 推荐(0)
摘要:import schedule import time def task(): print("任务启动了!") # 安排任务在16:59:59运行 schedule.every().day.at("16:59:59").do(task) while True: schedule.run_pendin 阅读全文
posted @ 2024-10-06 12:20 __username 阅读(37) 评论(0) 推荐(0)
摘要:推送消息到wx 基本代码 注意: import requests APPTOEKN = "AT_xxxxxxxxxxxxxxxxxxxxxxxxxx" UIDS = [ "UID_xxxxxxxxxxxxxxxxxxxxx", ] def send_message(msg,summary="test 阅读全文
posted @ 2024-10-03 12:21 __username 阅读(41) 评论(0) 推荐(0)
摘要:eg json.loads(response.text) response.text是json字符串 反之,用dumps 阅读全文
posted @ 2024-09-23 09:12 __username 阅读(9) 评论(0) 推荐(0)
摘要:verify=False,timeout=(1, 1) timeout只能在不要求结果的时候使用(即不需要请求的结果) 【更新,错误,会直接断了请求】 这两个参数=.= 阅读全文
posted @ 2024-08-23 13:15 __username 阅读(13) 评论(0) 推荐(0)

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