调整项目结构

This commit is contained in:
zw
2025-08-05 15:41:20 +08:00
parent aaf371a001
commit 1007415212
7 changed files with 135 additions and 254 deletions

29
Utils/AiUtils.py Normal file
View File

@@ -0,0 +1,29 @@
import os
import re
# 工具类
class AiUtils(object):
@classmethod
def findNumber(cls, str):
# 使用正则表达式匹配数字
match = re.search(r'\d+', str)
if match:
return int(match.group()) # 将匹配到的数字转换为整数
return None # 如果没有找到数字,返回 None
# 根据名称获取图片地址
@classmethod
def pathWithName(cls, name):
current_file_path = os.path.abspath(__file__)
# 获取当前文件所在的目录即script目录
current_dir = os.path.dirname(current_file_path)
# 由于script目录位于项目根目录下一级因此需要向上一级目录移动两次
project_root = os.path.abspath(os.path.join(current_dir, '..'))
# 构建资源文件的完整路径,向上两级目录,然后进入 resources 目录
resource_path = os.path.abspath(os.path.join(project_root, 'resources', name + ".jpg")).replace('/', '\\')
return resource_path