some changing
This commit is contained in:
41
test2.py
41
test2.py
@@ -2,37 +2,16 @@ import json
|
||||
|
||||
|
||||
def write_json(guild: int, param_name: str, param: str or int):
|
||||
with open('prefix.json', 'r+', encoding='utf-8') as _f:
|
||||
with open('prefix.json', 'r', 'utf-8') as _f:
|
||||
try:
|
||||
_jsonObject = json.load(_f)
|
||||
_json = json.load(_f)
|
||||
except json.decoder.JSONDecodeError:
|
||||
_jsonObject = {}
|
||||
_json = {}
|
||||
_json.update({f'{guild}': {}})
|
||||
print(_json)
|
||||
_guild = _json[f'{guild}']
|
||||
print(_guild)
|
||||
_guild.update({f'{param_name}': f'{param}'})
|
||||
print(_json)
|
||||
|
||||
try:
|
||||
_guild_conf = _jsonObject[f"{guild}"]
|
||||
except KeyError:
|
||||
_guild_conf = {f"{guild}": {}}
|
||||
|
||||
print(_jsonObject)
|
||||
print(_jsonObject)
|
||||
|
||||
try:
|
||||
_param = {f"{param_name}": f"{param}"}
|
||||
except KeyError:
|
||||
_param = {f"{param_name}": f"{param}"}
|
||||
print(_param)
|
||||
|
||||
_guild_conf.update(_param)
|
||||
print(_jsonObject)
|
||||
_jsonObject.update(_guild_conf)
|
||||
_guild_conf = _jsonObject[f"{guild}"]
|
||||
print(_jsonObject)
|
||||
print(_guild_conf)
|
||||
print(_param)
|
||||
|
||||
with open("prefix.json", "w") as _f:
|
||||
json.dump(_jsonObject, _f)
|
||||
_f.close()
|
||||
|
||||
|
||||
write_json(929446191270330452, 'rr', '34')
|
||||
write_json(929446191270330452, 'test1', '34')
|
||||
|
||||
Reference in New Issue
Block a user