# 我的第一个脚本 **Repository Path**: tlan_turing/my-first-script ## Basic Information - **Project Name**: 我的第一个脚本 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-04 - **Last Updated**: 2024-11-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 打包资源 from tools.resource_packer import ResourcePacker packer = ResourcePacker() packer.pack_directory('resources', 'dist_resources/resources.bin') # 读取资源 from utils.resource_reader import ResourceReader reader = ResourceReader('dist_resources/resources.bin') # 列出所有文件 print(reader.list_files()) # 读取特定文件 data = reader.read_file('scene1/img1.png') if data: # 使用文件数据 pass # 安装依赖 pip install -r requirements.txt # 程序打包 # 1. 创建测试函数 (functions/user.py) # 1. 创建测试函数 (functions/user.py) def get_user(): return { "name": "测试用户", "level": 1 } def check_permission(user_id: int) -> bool: return user_id > 0 # 2. 打包函数 from tools.python_packer import PythonPacker packer = PythonPacker() packer.pack_python_files('functions', 'dist_functions/functions.bin') # 3. 使用函数 from utils.python_loader import PythonLoader loader = PythonLoader('dist_functions/functions.bin') # 加载并使用函数 get_user = loader.load_function('user.py', 'get_user') if get_user: user_info = get_user() print(user_info) check_permission = loader.load_function('user.py', 'check_permission') if check_permission: has_permission = check_permission(1) print(has_permission) # 或者加载整个模块 user_module = loader.load_module('user.py') if user_module: user_info = user_module.get_user() print(user_info)