提问人:Alex 提问时间:1/30/2023 更新时间:2/1/2023 访问量:133
PyCharm 不显示西里尔文
PyCharm does not display Cyrillic
问:
帮助解决问题: 任务如下 - 将数据库模型保存在固定结构中。我使用终端(python manage.py dumpdata ... Json 文件已创建,但不显示西里尔文。UTF-8 编码,请帮忙。在此处输入图像描述 在此处输入图像描述
我尝试在设置中更改编码类型,我尝试手动重写json文件
答:
0赞
Alex
2/1/2023
#1
import json
file =
r'C:\Programming\python_django\store\products\fixtures\category.json'
file_2 =
r'C:\Programming\python_django\store\products\fixtures\category.json'
with open(file, 'rb') as open_file:
data = json.load(open_file)
with open(file_2, 'w') as write_file:
write_file.write(json.dumps(data, ensure_ascii=False,
indent=0,
separators=(',', ':
')).encode('cp866').decode('cp1251'))
评论
'╬фхцфр ═ютшэъш'.encode( 'cp866').decode( 'cp1251')
Одежда Новинки