windows下使用vscode连接linux服务器,不在项目目录下直接运行代码,工作区位置错误找不到 ‘./i18n/locale/en_US.json’

This commit is contained in:
wangyi 2024-07-13 10:52:41 +08:00
parent ea83174fe0
commit f883717926

View File

@ -2,6 +2,10 @@ import json
import locale
import os
# Get the directory where the script file is located
script_dir = os.path.dirname(os.path.abspath(__file__))
# Change the current working directory to the directory where the script is located
os.chdir(os.path.join(script_dir,'../../'))
def load_language_list(language):
with open(f"./i18n/locale/{language}.json", "r", encoding="utf-8") as f: