From cef0c721d5891ecebb589db848fa315490ce91a3 Mon Sep 17 00:00:00 2001 From: Ilia Miheev Date: Thu, 1 May 2025 21:33:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=20=D0=B4=D0=BB=D1=8F=20WorkWithJson=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B8=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BA=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D1=83=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ipars/module.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ipars/module.py b/ipars/module.py index 71ff85d..032c8d9 100644 --- a/ipars/module.py +++ b/ipars/module.py @@ -41,16 +41,20 @@ class WorkWithScv: class WorkWithJson: '''Модуль для работы с json файлами''' + + def __init__(self, encoding:str='utf8'): + self.encoding = encoding + def load(self, pathToJsonFile:str): """Получаем данные из json файла""" - with open(pathToJsonFile) as jsonFile: + with open(pathToJsonFile, encoding=self.encoding) as jsonFile: src = json.load(jsonFile) return src def dump(self, pathToJsonFile:str, data:any): """Записываем данные в json файл""" - with open(pathToJsonFile, 'w', encoding='utf8') as jsonFile: + with open(pathToJsonFile, 'w', encoding=self.encoding) as jsonFile: json.dump(data, jsonFile, indent=4, ensure_ascii=0)