avatar
Articles
292
Tags
211
Categories
0

karr's blog
Search

karr's blog

flask orm 对象序列化
Created2024-04-07
12345678def orm_serialize(item) -> dict: if item: try: return {c.name: getattr(item, c.name) for c in item.__table__.columns} except: return {} else: return {}
es6完全深拷贝一个对象
Created2024-03-29
123export const deepClone = (obj: object) => { return JSON.parse(JSON.stringify(obj));}
编辑距离算法
Created2024-03-29
1234567891011121314151617181920212223242526272829303132333435const levenshteinDistance = (str1: string, str2: string) => { const len1 = str1.length; const len2 = str2.length; const matrix: Array<number[]> = []; // 初始化第一行 for (let i = 0; i <= len1; i++) { matrix[i] = [i]; } // 初始化第一列 for (let j = 0; j <= len2; j++) { matrix[0][j] = j; } // 填充矩阵 for (let i = 1; i <= len1; i++) { for (let j = 1; j ...
es6过滤对象的某个属性
Created2024-03-27
使用 Object.entries() 方法将对象转换成一个键值对的数组,然后使用 reduce() 方法遍历这个数组并过滤掉不需要的属性。最后,使用一个空对象作为累加器(acc),将过滤后的属性存储到这个对象中。 123456789const fields = { name: "xxx", age: 18, other: null}const filteredFields = Object.entries(fields).reduce((acc, [key, value]) => { if (key && value) { acc[key] = value; } return acc;}, {});console.log(filteredFields)
flask-sqlalchemy orm 框架序列化
Created2024-03-19
123# 如果对象是ORM对象,则将其转换为字典并返回if isinstance(obj.__class__, DeclarativeMeta): return {c.name: getattr(obj, c.name) for c in obj.__table__.columns}
celery flower api 接口认证
Created2024-03-19
12345678auth_user = 'admin'auth_passwd = '123456'usrPass = "%s:%s" % (auth_user, auth_passwd)b64Val = base64.b64encode(usrPass.encode('utf-8'))headers = { "Authorization": "Basic %s" % b64Val.decode(),}print(headers)
git回滚
Created2024-03-04
版本回退1git reset --hard <目标版本号> 强制推送1git push -f
统计80端口连接数
Created2024-03-04
1netstat -nat|grep -i "80"|wc -l
Python 中动态调用函数或类的方法
Created2024-02-27
使用 importlib123456789101112131415161718# module.pyclass A: def foo(self): print('this is foo.') @staticmethod def static_method(): print('this is static.')def bar(): print('bar……')def baz(): print('==baz==') 这种方式其实是__import__() 方式的扩展。Python官方文档推荐程序式地导入模块时应该使用 import_module() 而不是__import__。这里我们继续使用上面定义好的module.py模块。 1234567891011# main.pyimport importlibmodule_name = 'module'module_obj = importlib.import_module(module ...
SQLAlchemy commit 后会自动重新查询数据库问题
Created2024-02-24
1expire_on_commit=False
1…111213…30
avatar
karr
世界那么大,我想去看看。
Articles
292
Tags
211
Categories
0
gitee
Announcement
This is my Blog
Recent Post
python 使用线程池来同时执行多个函数2025-07-23
获取 A 股全部历史数据保存到本地2025-07-22
What are AI Agents?2025-07-21
Hello, 极简AES!2025-07-20
Git报错: Failed to connect to github.com port 443 解决方案2025-03-30
Tags
memory_profiler mysqlclient react-error utils OTP io多路复用 importlib postMessage 字典 救猫咪 数据库 text npm 协程 react-warning git-lfs Artificial Intelligence vue-router Android 前端 变现 Homebrew commit message 重复数据 动态口令 Next-key lock stopPropagation ONLY_FULL_GROUP_BY react-fragment-error-message 代码 口罩检测系统 react-props-warning-message 远程仓库 FastAPI eslint es6 GROUP BY 搜索引擎 md5 react-text-error-message
Archives
  • July 20254
  • March 20256
  • February 20252
  • January 20253
  • November 20242
  • October 20243
  • September 20247
  • August 202410
Info
Article :
292
UV :
PV :
Last Update :
©2024 - 2025 By karr
Framework Hexo|Theme Butterfly
Search
Loading the Database