当前位置: 首页 > article >正文

将Sqlite3数据库挂在内存上处理

创作灵感:最近把小学生的口算题从2位数改到3位数,100以内四则运算练习(千纬数学)再次更新,选取难题-CSDN博客要不断刷题目,以前100以内的加减乘除也是这样刷出来的,代码如下:

import sqlite3
import random
from time import time
from pathlib import Path#导入必要的库resources_folder = Path(__file__).joinpath("../resources/").resolve()
db_filepath = resources_folder.joinpath("qwsx.db")
#db_filepath = '/storage/emulated/0/Pictures/qwsx.db'
#上面是数据库的存放位置,生成手机app请参考我以前的文章
#oppo版 需要用电脑调试应删除下面5行def gettid(s1,fh,s2,dan):conn = sqlite3.connect(db_filepath, timeout=10, check_same_thread=False)c = conn.cursor()#如果公式存在,提取tidcursor = c.execute("SELECT count(tid) from ys where s1 = ? and fh = ? and s2 = ?;", (s1,fh,s2,))row = cursor.fetchone()ctid = row[0]#如果公式不存在,插入公式到数据库if ctid == 0:c.execute("INSERT INTO ys(s1,fh,s2,dan,cs,cuo) VALUES (?,?,?,?,0,0);", (s1,fh,s2,dan,))conn.commit()cursor = c.execute("SELECT tid from ys where s1 = ? and fh = ? and s2 = ? order by tid desc;", (s1,fh,s2,))row = cursor.fetchone()tid = row[0] c.close()conn.close()return(tid)
#获取tid,题目的id
def settm(nd):    if nd ==1:jj = random.randint(0,1)elif nd ==2:jj = random.randint(0,3)if jj == 0:#为加法 s1 = random.randint(0,100)s2 = random.randint(0,(100 - s1))cvalue = str(s1) + "+" + str(s2) + "=" dan = s1 + s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□+" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3:cvalue = str(s1) + "+□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 > 0:#a+0=a,a-0=a,可以是+-cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==1:s1 = random.randint(0,100)s2 = random.randint(0,s1)cvalue = str(s1) + "-" + str(s2) + "=" dan = s1 - s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□-" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3:cvalue = str(s1) + "-□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 > 0:#a+0=a,a-0=a,可以是+-cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==2:#乘法s1 = random.randint(1,10)s2 = random.randint(0,int(100 / s1))cvalue = str(s1) + "×" + str(s2) + "="dan = s1 * s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□×" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3 and s2 > 0:#a*0=0,b*0=0cvalue = str(s1) + "×□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 !=1 and s1 != 0:#a*=a,a/1=a;0*a=0,0/a=0cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==3:s1 = random.randint(1,10)s2 = random.randint(0,int(100 / s1))s3 = s1dan = s1 * s2s1 = dans2 = s3cvalue = str(s1) + "÷" + str(s2) + "=" dan = int(s1 / s2)hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□÷" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3 and s1 > 0:#0/a=0cvalue = str(s1) + "÷□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 !=1 and s1 !=0:#a*=a,a/1=a;0*a=0,0/a=0cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号cid = 0return(jj,dan,hd,cid,tid,cvalue)i = 0
while i < 1000000:settm(2)i=i+1

上面代码就是刷题100万次,让电脑随机出题。实际能够存入数据库的题目只有1万条。所以当初刷题的时候没有考虑计算机的运行效率和对资源的消耗,从上面程序看,每运行一次就要从硬盘读取数据库文件一次。这次不知道要刷题多少次才能将3位数以内的算式。问下deepseek:

官网的罢工:

用下国家超算平台DeepSeek的:

最终答案:

两个1至3位数相加或相减,得数在0到999范围内的所有算式共有 998,001 条。

再加上200以内的乘法和除法:

经过上述计算,我们得出所有满足条件的算式共有 2000 个。

除法应该在2000个以内。

下面是随机生成的代码:

import sqlite3
import random
from time import time
from pathlib import Path
import datetime
#导入必要的库resources_folder = Path(__file__).joinpath("../resources/").resolve()
db_filepath = resources_folder.joinpath("qwsx.db")
#db_filepath = '/storage/emulated/0/Pictures/qwsx.db'
#上面是数据库的存放位置,生成手机app请参考我以前的文章
#oppo版 需要用电脑调试应删除下面5行
for j in range(0,10):# 连接到磁盘上的数据库disk_conn = sqlite3.connect(db_filepath)# 连接到内存数据库memory_conn = sqlite3.connect(':memory:')# 使用 backup API 将磁盘数据库复制到内存数据库disk_conn.backup(memory_conn)xt = 0def gettid(s1,fh,s2,dan):global xtconn = memory_connc = conn.cursor()#如果公式存在,提取tidcursor = c.execute("SELECT count(tid) from ys where s1 = ? and fh = ? and s2 = ?;", (s1,fh,s2,))row = cursor.fetchone()ctid = row[0]#如果公式不存在,插入公式到数据库if ctid == 0:c.execute("INSERT INTO ys(s1,fh,s2,dan,cs,cuo) VALUES (?,?,?,?,0,0);", (s1,fh,s2,dan,))conn.commit()# print(s1,fh,s2,dan)else:# print('与数据库存在相同')xt = xt + 1cursor = c.execute("SELECT tid from ys where s1 = ? and fh = ? and s2 = ? order by tid desc;", (s1,fh,s2,))row = cursor.fetchone()tid = row[0] c.close()return(tid)#获取tid,题目的iddef settm(nd):    if nd ==1:jj = random.randint(0,1)elif nd ==2:jj = random.randint(0,3)if jj == 0:#为加法 s1 = random.randint(0,999)s2 = random.randint(0,(999 - s1))cvalue = str(s1) + "+" + str(s2) + "=" dan = s1 + s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□+" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3:cvalue = str(s1) + "+□=" + str(dan) + ",□为"dan = s2elif ii == 4 and s2 > 0:#a+0=a,a-0=a,可以是+-cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==1:s1 = random.randint(0,999)s2 = random.randint(0,s1)cvalue = str(s1) + "-" + str(s2) + "=" dan = s1 - s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□-" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3:cvalue = str(s1) + "-□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 > 0:#a+0=a,a-0=a,可以是+-cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==2:#乘法s1 = random.randint(1,200)s2 = random.randint(0,int(200 / s1))cvalue = str(s1) + "×" + str(s2) + "="dan = s1 * s2hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□×" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3 and s2 > 0:#a*0=0,b*0=0cvalue = str(s1) + "×□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 !=1 and s1 != 0:#a*=a,a/1=a;0*a=0,0/a=0cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号elif jj ==3:s1 = random.randint(1,200)s2 = random.randint(0,int(200 / s1))s3 = s1dan = s1 * s2s1 = dans2 = s3cvalue = str(s1) + "÷" + str(s2) + "=" dan = int(s1 / s2)hd = 1tid = gettid(s1,jj,s2,dan)ii = random.randint(0,4) #0为提交答案if ii == 2:cvalue = "□÷" + str(s2) + "=" + str(dan) + ",□为"dan = s1elif ii == 3 and s1 > 0:#0/a=0cvalue = str(s1) + "÷□=" + str(dan) + ",□为"dan = s2elif ii ==4 and s2 !=1 and s1 !=0:#a*=a,a/1=a;0*a=0,0/a=0cvalue = str(s1) + "□" + str(s2) + "=" + str(dan) + ",□为"dan = jjhd = 4 #hd4为符号cid = 0return(jj,dan,hd,cid,tid,cvalue)print(datetime.datetime.now())i = 0while i < 50000:settm(1)i=i+1print(f'与原来数据库存在{xt}个相同。')print(datetime.datetime.now())# 将内存数据库的内容写回磁盘数据库memory_conn.backup(disk_conn)# 关闭连接disk_conn.close()memory_conn.close()

这样要形成一个随机的表,太慢了,运行了半天:

2025-02-12 23:19:25.515728
与原来数据库存在25585个相同。
2025-02-13 00:10:52.646772
2025-02-13 00:10:52.894585
与原来数据库存在26770个相同。
2025-02-13 01:04:37.832301
2025-02-13 01:04:38.108767
与原来数据库存在27902个相同。
2025-02-13 02:01:26.172076
2025-02-13 02:01:26.429696
与原来数据库存在28961个相同。
2025-02-13 03:01:18.825697
2025-02-13 03:01:19.081742
与原来数据库存在30000个相同。
2025-02-13 04:03:55.562965
2025-02-13 04:03:55.833989
与原来数据库存在30767个相同。
2025-02-13 05:09:20.222007
2025-02-13 05:09:20.711048
与原来数据库存在31616个相同。
2025-02-13 06:16:58.876971
2025-02-13 06:16:59.169436
与原来数据库存在32288个相同。
2025-02-13 07:27:02.256963
2025-02-13 07:27:02.546013
与原来数据库存在33187个相同。
2025-02-13 08:42:14.837606
2025-02-13 08:42:15.139579
与原来数据库存在33747个相同。
2025-02-13 09:57:30.281790

而且,接下来要生成数据库不存在的公式,将越来越少。所以不如按顺序全部生成,不用1分钟就完成:

import sqlite3
import random
from time import time
from pathlib import Path
import datetime
#导入必要的库resources_folder = Path(__file__).joinpath("../resources/").resolve()
db_filepath = resources_folder.joinpath("qwsx.db")
#db_filepath = '/storage/emulated/0/Pictures/qwsx.db'
#上面是数据库的存放位置,生成手机app请参考我以前的文章
#oppo版 需要用电脑调试应删除下面5行# 连接到磁盘上的数据库
disk_conn = sqlite3.connect(db_filepath)# 连接到内存数据库
memory_conn = sqlite3.connect(':memory:')# 使用 backup API 将磁盘数据库复制到内存数据库
disk_conn.backup(memory_conn)def gettid(s1,fh,s2,dan):conn = memory_connc = conn.cursor()#如果公式存在,提取tidc.execute("INSERT INTO ysall(s1,fh,s2,dan,cs,cuo) VALUES (?,?,?,?,0,0);", (s1,fh,s2,dan,))conn.commit()c.close()return(1)
#获取tid,题目的id
def settm(jj):if jj == 0:#为加法 for s1 in range(0,1000):for s2 in range(0,(1000 - s1)):dan = s1 + s2tid = gettid(s1,jj,s2,dan)cvalue = str(s1) + "+" + str(s2) + "=" + str(dan)print(cvalue)elif jj ==1:for s1 in range(0,1000):for s2 in range(0,s1 + 1):dan = s1 - s2tid = gettid(s1,jj,s2,dan)cvalue = str(s1) + "-" + str(s2) + "=" + str(dan)print(cvalue)elif jj ==2:#乘法for s1 in range(1,201):for s2 in range(0,int(200 / s1) + 1):dan = s1 * s2tid = gettid(s1,jj,s2,dan)cvalue = str(s1) + "×" + str(s2) + "=" + str(dan)print(cvalue)elif jj ==3:ii = 0for s1 in range(1,201):# print(s1)s3 = s1for s2 in range(0,int(200 / s1) + 1):ii = ii + 1# print(s3)dan = s1 * s2ss1 = danss2 = s3sdan = int(ss1 / ss2)tid = gettid(ss1,jj,ss2,sdan)cvalue = str(ss1) + "÷" + str(ss2) + "=" + str(sdan)print(cvalue)print(ii)return(jj,dan,tid,cvalue)
print(datetime.datetime.now())
settm(3)
print(datetime.datetime.now())
# 将内存数据库的内容写回磁盘数据库
memory_conn.backup(disk_conn)# 关闭连接
disk_conn.close()
memory_conn.close()

在对这些数据进行随机写入:

# -*- coding: utf-8 -*-
"""
Created on Thu Feb 13 10:47:16 2025@author: YBK
"""
import sqlite3
import random
from pathlib import Pathresources_folder = Path(__file__).joinpath("../resources/").resolve()
db_filepath = resources_folder.joinpath("qwsx.db")
# 连接到磁盘上的数据库
disk_conn = sqlite3.connect(db_filepath)
# 连接到内存数据库
memory_conn = sqlite3.connect(':memory:')
# 使用 backup API 将磁盘数据库复制到内存数据库
disk_conn.backup(memory_conn)conn = memory_conn
c = conn.cursor()
#如果公式存在,提取tid
cursor = c.execute("SELECT tid from ysall;")
rows = cursor.fetchall()
ysshun = [row[0] for row in rows]
print(len(ysshun))
random.shuffle(ysshun)
for tid in ysshun:cursor = c.execute("SELECT s1,fh,s2,dan from ysall where tid = ?;",(tid,))row = cursor.fetchone()c.execute("INSERT INTO ys(s1,fh,s2,dan,cs,cuo) VALUES (?,?,?,?,0,0);", (row[0],row[1],row[2],row[3],))conn.commit()
c.close# 将内存数据库的内容写回磁盘数据库
memory_conn.backup(disk_conn)# 关闭连接
disk_conn.close()
memory_conn.close()

不用1分钟就能完成。

######################################################

因为我原来数据库有2位数的加减乘除算式,所以这次只是将3位数的算式加上去,为保留原有数据的内容,只需要对原来数据中没有的数据加上去就可以,为了提高速度,在生成随机列表后,对原有公式一致的tid删除即可,删除1万来行。

# -*- coding: utf-8 -*-
"""
Created on Thu Feb 13 10:47:16 2025@author: YBK
"""
import sqlite3
import random
from pathlib import Pathresources_folder = Path(__file__).joinpath("../resources/").resolve()
db_filepath = resources_folder.joinpath("qwsx.db")
# 连接到磁盘上的数据库
disk_conn = sqlite3.connect(db_filepath)
# 连接到内存数据库
memory_conn = sqlite3.connect(':memory:')
# 使用 backup API 将磁盘数据库复制到内存数据库
disk_conn.backup(memory_conn)conn = memory_conn
c = conn.cursor()
#如果公式存在,提取tid
cursor = c.execute("SELECT tid from ysall;")
rows = cursor.fetchall()
ysshun = [row[0] for row in rows]
print(len(ysshun))
random.shuffle(ysshun)
#找出所有旧数据库有的tid,在列表中删除掉
cursor = c.execute("SELECT s1,fh,s2,dan from ys;")
rows = cursor.fetchall()
for row in rows:s1 = row[0]fh = row[1]s2 = row[2]cursor = c.execute("SELECT tid from ysall where s1 = ? and fh = ? and s2 = ?;", (s1,fh,s2,))row = cursor.fetchone()if row:ctid = row[0]        ysshun.remove(ctid)print(f'删除{ctid}')else:print(f'{s1},{fh},{s2}不存在') 
#插入删除已经有的公式后没有的数据
for tid in ysshun:cursor = c.execute("SELECT s1,fh,s2,dan from ysall where tid = ?;",(tid,))row = cursor.fetchone()s1 = row[0]fh = row[1]s2 = row[2]dan = row[3]c.execute("INSERT INTO ys(s1,fh,s2,dan,cs,cuo) VALUES (?,?,?,?,0,0);", (s1,fh,s2,dan,))conn.commit()
c.close# 将内存数据库的内容写回磁盘数据库
memory_conn.backup(disk_conn)# 关闭连接
disk_conn.close()
memory_conn.close()

相关文章:

将Sqlite3数据库挂在内存上处理

创作灵感&#xff1a;最近把小学生的口算题从2位数改到3位数&#xff0c;100以内四则运算练习&#xff08;千纬数学&#xff09;再次更新&#xff0c;选取难题-CSDN博客要不断刷题目&#xff0c;以前100以内的加减乘除也是这样刷出来的&#xff0c;代码如下&#xff1a; impor…...

Vue3.5 企业级管理系统实战(六):Vue3中defineProps用法

上一节封装图标组件 SvgIcon 时&#xff0c;用到了 defineProps&#xff0c;因为它在开发中的重要性&#xff0c;这里简单看一下它的用法&#xff0c;已熟知用法的此节可跳过。 在 Vue3 的组件化开发体系里&#xff0c;组件间通信是构建高效、可维护应用程序的核心环节。defin…...

HTTP/2 由来及特性

HTTP/2 的由来 HTTP/1.x 的局限性 性能瓶颈 队头阻塞问题&#xff1a;在HTTP/1.x中&#xff0c;一个TCP连接在同一时间只能处理一个请求&#xff0c;后续请求必须等待前面的请求处理完成并收到响应后才能被处理。例如&#xff0c;当一个页面有多个资源&#xff08;如图片、脚…...

electron.vite 项目创建以及better-sqlite3数据库使用

1.安装electron.vite npm create quick-start/electronlatest中文官网&#xff1a;https://cn.electron-vite.org/ 2. 安装项目依赖 npm i3.修改 electron-builder 配置文件 appId: com.electron.app productName: text33 directories:buildResources: build files:- !**/.v…...

蓝桥杯 Java B 组之枚举算法(暴力破解)

Day 3&#xff1a;枚举算法&#xff08;暴力破解&#xff09; 枚举算法&#xff08;Brute Force&#xff09;是一种 暴力搜索 方法&#xff0c;它通过 遍历所有可能的情况 来找到正确答案。虽然它的 时间复杂度较高&#xff0c;但在 数据范围较小 时&#xff0c;它是一种简单且…...

AI 控制web浏览器基础知识准备,名词解释Xvfb,x11vnc,novnc,playwright,gradio

在探索如何让AI控制Web浏览器实现自动化任务时&#xff0c;了解底层技术栈是关键。本文将解析五个核心组件&#xff1a;Xvfb、x11vnc、novnc、playwright和gradio&#xff0c;这些工具共同构成了AI驱动浏览器的基础架构。 1. Xvfb&#xff08;X Virtual Framebuffer&#xff0…...

C++,STL容器适配器,stack:栈深入解析

文章目录 一、容器概览与核心特性核心特性速览二、底层实现原理1. 容器适配器设计2. 默认容器对比三、核心操作详解1. 容器初始化2. 元素操作接口3. 自定义栈实现四、实战应用场景1. 括号匹配校验2. 浏览器历史记录管理五、性能优化策略1. 底层容器选择基准2. 内存预分配技巧六…...

Vue笔记(十)

一、AI的基本认知 二、ChatGPT的基本使用 三、AI插件--Copilot入门 1.Copilot是由OpenAI和GitHub合作开发的AI编程辅助插件&#xff0c;基于大量代码训练&#xff0c;能根据上下文自动生成代码建议。 2.安装与配置&#xff1a;在常用代码编辑器&#xff08;如Visual Studio Cod…...

Ubuntu下载安装Docker-Desktop

下载 Ubuntu | Docker Docs 预备工作 Ubuntu增加docker apt库-CSDN博客 安装 sudo apt-get updatesudo apt install gnome-terminal# sudo apt install -y docker-composesudo apt-get install ./docker-desktop-amd64.deb 测试 sudo docker run hello-worldHello from D…...

DeepSeek 突然来袭,AI 大模型变革的危机与转机藏在哪?

随着人工智能技术的飞速发展&#xff0c;大模型领域不断涌现出具有创新性的成果。DeepSeek 的横空出世&#xff0c;为 AI 大模型领域带来了新的变革浪潮。本文将深入探讨 DeepSeek 出现后 AI 大模型面临的危机与转机。 冲冲冲&#xff01;&#xff01;&#xff01; 目录 一、…...

C#运动控制——轴IO映射

1、IO映射的作用 该功能允许用户对专用 IO 信号的硬件输入接口进行任意配置&#xff0c;比如轴的急停信号&#xff0c;通过映射以后&#xff0c;可以将所有轴的急停信号映射到某一个IO输入口上&#xff0c;这样&#xff0c;我们只要让一个IO信号有效就可以触发所有轴的急停。 进…...

ArrayList、LinkedList、HashMap、HashTable、HashSet、TreeSet

集合族谱 在这些集合中&#xff0c;仅有vector和hashtable是线程安全的&#xff0c;其内部方法基本都有synchronized修饰。 ArrayList 底层采用Object数组实现&#xff0c;实现了RandomAccess接口因此支持随机访问。插入删除操作效率慢。 ArrayList需要一份连续的内存空间。 A…...

DeepSeek 指导手册(入门到精通)

第⼀章&#xff1a;准备篇&#xff08;三分钟上手&#xff09;1.1 三分钟创建你的 AI 伙伴1.2 认识你的 AI 控制台 第二章&#xff1a;基础对话篇&#xff08;像交朋友⼀样学交流&#xff09;2.1 有效提问的五个黄金法则2.2 新手必学魔法指令 第三章&#xff1a;效率飞跃篇&…...

window 11 鼠标右键切换回经典模式

window 11 鼠标右键切换回经典模式 在换新电脑&#xff0c;更新到 window 11 后&#xff0c;鼠标右键很不习惯&#xff0c;把很多功能都隐藏到最后一个打开更多模块了&#xff0c;删除以及刷新等操作也不能使用右键字母快捷操作。 恢复window 11 右键菜单到经典模式 方法一&am…...

RabbitMQ 延迟队列

1.延迟队列插件安装(版本号要对其&#xff09; Releases rabbitmq/rabbitmq-delayed-message-exchange GitHub 下载的文件: rabbitmq_delayed_message_exchange-3.13.0.ez 直接复制到以下文件夹&#xff1a; \RabbitMQ Server\rabbitmq_server-3.13.7\plugins\ 执行命令…...

Unity3D 类MOBA角色控制器 开箱即用

Github: Unity3D-MOBA-Character-Controller 觉得好用麻烦点个Star感谢&#xff01;...

认识一下redis的分布式锁

Redis的分布式锁是一种通过Redis实现的分布式锁机制&#xff0c;用于在分布式系统中确保同一时刻只有一个客户端可以访问某个资源。它通常用于防止多个应用实例在同一时间执行某些特定操作&#xff0c;避免数据的不一致性或竞争条件。 实现分布式锁的基本思路&#xff1a; 1. …...

【CXX】0 Rust与C ++的互操作利器:CXX库介绍与示例

CXX库是一个非常强大的工具&#xff0c;它使得Rust和C之间的互操作性变得既安全又高效。本专栏将展示如何使用CXX库来桥接Rust和C代码&#xff0c;同时保持两者语言的特性和惯用法。 一、关键概念 类型安全&#xff1a;CXX库通过静态分析类型和函数签名来保护Rust和C的不变量…...

2024 CyberHost 语音+图像-视频

项目&#xff1a;CyberHost: Taming Audio-driven Avatar Diffusion Model with Region Codebook Attention 音频驱动的身体动画面临两个主要挑战&#xff1a;&#xff08;1&#xff09;关键人体部位&#xff0c;如面部和手部&#xff0c;在视频帧中所占比例较小&#x…...

企业文件安全:零信任架构下的文件访问控制

在企业数字化转型的进程中&#xff0c;传统的文件访问控制模型已难以满足日益复杂的网络安全需求。零信任架构作为一种新兴的安全理念&#xff0c;为企业的文件安全访问提供了全新的解决方案。 一、传统文件访问控制的局限性 传统的文件访问控制主要基于网络边界&#xff0c;…...

Rasa学习笔记

一、CALM 三个关键要素&#xff1a; 业务逻辑&#xff1a;Flow&#xff0c;描述了AI助手可以处理的业务流程对话理解&#xff1a;旨在解释最终用户与助手沟通的内容。此过程涉及生成反映用户意图的命令&#xff0c;与业务逻辑和正在进行的对话的上下文保持一致。自动对话修复…...

list_for_each_entry_safe 简介

list_for_each_entry_safe 是 Linux 内核中用于遍历链表的一个宏&#xff0c;特别适用于在遍历过程中可能需要删除链表节点的场景。它的设计保证了在删除当前节点时&#xff0c;不会影响后续节点的访问&#xff0c;从而实现安全的遍历。 定义 #define list_for_each_entry_sa…...

Android 系统面试问题

一.android gki和非gki的区别 Android GKI&#xff08;Generic Kernel Image&#xff09;和非GKI内核的主要区别在于内核设计和模块化程度&#xff0c;具体如下&#xff1a; 1. 内核设计 GKI&#xff1a;采用通用内核设计&#xff0c;与设备硬件分离&#xff0c;核心功能统一…...

【面试集锦】如何设计SSO方案?和OAuth有什么区别?

如何设计SSO方案?和OAuth有什么区别?--楼兰 带你聊最纯粹的Java ​ 如果面试问你,你会做一个权限系统吗?那你肯定会说做过。不就是各种登录、验证吗。我做的第一个CRUD应用就是注册、登录。简单!但是,如果问你在工作中真的做过权限系统吗?其实很多人都只能默默摇摇头。因…...

二十六、使用docsify搭建文档管理平台

特性 无需构建,写完文档直接发布容易使用并且轻量 (~19kB gzipped)智能的全文搜索提供多套主题丰富的 API...

bitcoinjs学习1—P2PKH

1. 概述 在本学习笔记中&#xff0c;我们将深入探讨如何使用 bitcoinjs-lib 库构建和签名一个 P2PKH&#xff08;Pay-to-PubKey-Hash&#xff09; 比特币交易。P2PKH 是比特币网络中最常见和最基本的交易类型之一&#xff0c;理解其工作原理是掌握比特币交易构建的关键。 想要详…...

如何在 Java 应用中实现数据库的主从复制(读写分离)?请简要描述架构和关键代码实现?

在Java应用中实现数据库主从复制&#xff08;读写分离&#xff09; 一、架构描述 &#xff08;一&#xff09;整体架构 主库&#xff08;Master&#xff09; 负责处理所有的写操作&#xff08;INSERT、UPDATE、DELETE等&#xff09;。它是数据的源头&#xff0c;所有的数据变…...

【pytest】获取所有用例名称并存于数据库

数据库操作包&#xff0c;引用前面创建的py文件&#xff0c;【sqlite】python操作sqlite3&#xff08;含测试&#xff09; #!/usr/bin/env python # -*- coding: utf-8 -*- # Time : 2025-02-11 8:45 # Author : duxiaowei # File : get_filename.py # Software: 这个文…...

【论文笔记】Are Self-Attentions Effective for Time Series Forecasting? (NeurIPS 2024)

官方代码https://github.com/dongbeank/CATS Abstract 时间序列预测在多领域极为关键&#xff0c;Transformer 虽推进了该领域发展&#xff0c;但有效性尚存争议&#xff0c;有研究表明简单线性模型有时表现更优。本文聚焦于自注意力机制在时间序列预测中的作用&#xff0c;提…...

maven导入spring框架

在eclipse导入maven项目&#xff0c; 在pom.xml文件中加入以下内容 junit junit 3.8.1 test org.springframework spring-core ${org.springframework.version} org.springframework spring-beans ${org.springframework.version} org.springframework spring-context ${org.s…...