| 1234567891011121314151617181920212223242526272829303132333435 |
- import re
- import os
- # 获取脚本所在目录
- script_dir = os.path.dirname(os.path.abspath(__file__))
- # 需要修复的文件列表
- files_to_fix = [
- 'routers/chat.py',
- 'routers/scene.py',
- 'routers/hazard.py'
- ]
- for file_path in files_to_fix:
- full_path = os.path.join(script_dir, file_path)
- if not os.path.exists(full_path):
- print(f'文件不存在: {full_path}')
- continue
-
- print(f'正在修复: {file_path}')
-
- # 读取文件
- with open(full_path, 'r', encoding='utf-8') as f:
- content = f.read()
-
- # 替换所有 user.user_id 为 user.userCode
- new_content = re.sub(r'user\.user_id', 'user.userCode', content)
-
- # 写回文件
- with open(full_path, 'w', encoding='utf-8') as f:
- f.write(new_content)
-
- print(f'✓ {file_path} 修复完成')
- print('\n所有文件修复完成!')
|