TG-PlatformPlus/qml/debug/motor/script/agr.py

24 lines
600 B
Python

import json
import sys
from PyQt6 import *
from PyQt6.QtCore import *
class Agr(QObject):
def __init__(self):
super().__init__()
@pyqtSlot(str, QVariant)
def setJson(self,path,data):
data = data.toVariant()
# filePath = os.path.join(path, self.appId)
with open(path, 'w',encoding='utf-8') as file:
json.dump(data, file, ensure_ascii=False, indent=4)
@pyqtSlot(str,result=QVariant)
def getJson(self, path):
with open(path, 'r',encoding='utf-8') as file:
data = json.load(file)
return data
agr = Agr()