项目基础模块代码

This commit is contained in:
2025-02-19 11:47:33 +08:00
parent 3cb2a4c507
commit 31302bcd17
30 changed files with 588 additions and 74 deletions

12
app/util/random_utils.py Normal file
View File

@ -0,0 +1,12 @@
import random
import string
def random_str(length=10):
"""随机生成自定义长度的小写字母"""
letters = string.ascii_lowercase
# 使用 random.choices 从 letters 中随机选择 length 个字母,返回一个列表
random_letters = random.choices(letters, k=length)
# 将列表中的字母连接成一个字符串
return ''.join(random_letters)