簡體   English   中英

PyCharm不顯示西里爾文

[英]PyCharm does not display Cyrillic

幫助解決問題:任務如下 - 將數據庫 model 保存在固定結構中。 我是使用終端 (python manage.py dumpdata...) 完成的 Json 文件已創建但不顯示西里爾字母。 utf-8編碼,請幫忙。 在此輸入圖片描述 在輸入圖片描述

我嘗試在設置中更改編碼類型,我嘗試手動重寫 json 文件

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'))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM