delete:encoding convert
This commit is contained in:
@@ -1,22 +0,0 @@
|
|||||||
# 获取文件编码
|
|
||||||
import chardet
|
|
||||||
|
|
||||||
|
|
||||||
def get_encoding(file):
|
|
||||||
with open(file, 'rb') as f:
|
|
||||||
return chardet.detect(f.read())['encoding']
|
|
||||||
|
|
||||||
|
|
||||||
# 将其他编码的文件转换为UTF-8编码
|
|
||||||
def other2utf8(file, encoding):
|
|
||||||
with open(file, 'r', encoding=encoding) as f:
|
|
||||||
lines = f.readlines()
|
|
||||||
with open(file, 'w', encoding='utf-8') as f:
|
|
||||||
f.writelines(lines)
|
|
||||||
|
|
||||||
|
|
||||||
# 获取文件编码,如果为utf-8编码,就转换为gbk编码
|
|
||||||
def convert_encoding(file):
|
|
||||||
encoding = get_encoding(file)
|
|
||||||
if encoding != 'utf-8':
|
|
||||||
other2utf8(file, encoding)
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
from starlette.config import Config
|
from starlette.config import Config
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
# import encoding_convert
|
|
||||||
|
|
||||||
# 配置文件.env
|
# 配置文件.env
|
||||||
# 请将.env移动至data目录,方便docker部署
|
# 请将.env移动至data目录,方便docker部署
|
||||||
@@ -9,9 +8,6 @@ import shutil
|
|||||||
if os.path.exists('.env'):
|
if os.path.exists('.env'):
|
||||||
# 将文件复制到data目录
|
# 将文件复制到data目录
|
||||||
shutil.copy('.env', 'data/.env')
|
shutil.copy('.env', 'data/.env')
|
||||||
# if os.path.exists('data/.env'):
|
|
||||||
# # 获取data目录下的.env文件编码,如果为utf-8编码,就转换为gbk编码
|
|
||||||
# encoding_convert.convert_encoding('./data/.env')
|
|
||||||
|
|
||||||
config = Config("data/.env")
|
config = Config("data/.env")
|
||||||
# 是否开启DEBUG模式
|
# 是否开启DEBUG模式
|
||||||
|
|||||||
Reference in New Issue
Block a user