mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
修复json读取
This commit is contained in:
parent
fa12023db0
commit
257bac7edc
@ -13,7 +13,7 @@ import datetime
|
|||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
user_cookies = {
|
user_cookies_example = {
|
||||||
"通用": [
|
"通用": [
|
||||||
{
|
{
|
||||||
"cookie": "",
|
"cookie": "",
|
||||||
@ -24,20 +24,21 @@ user_cookies = {
|
|||||||
"no": 2
|
"no": 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"私人":{
|
"私人":{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
user_cookies = {}
|
||||||
def load_data():
|
def load_data():
|
||||||
path = os.path.join(os.path.dirname(__file__), 'user_data','user_cookies.json')
|
path = os.path.join(os.path.dirname(__file__), 'user_data','user_cookies.json')
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
with open(path,'w',encoding='UTF-8') as f:
|
with open(path,'w',encoding='UTF-8') as f:
|
||||||
json.dump(user_cookies,f,ensure_ascii=False)
|
json.dump(user_cookies_example,f,ensure_ascii=False)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(path, encoding='utf8') as f:
|
with open(path, encoding='utf8') as f:
|
||||||
user_cookies = json.load(f)
|
data = json.load(f)
|
||||||
|
for k, v in data.items():
|
||||||
|
user_cookies[k] = v
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ def load_data():
|
|||||||
path = os.path.join(os.path.dirname(__file__), 'myb_info.json')
|
path = os.path.join(os.path.dirname(__file__), 'myb_info.json')
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
with open(path,'w',encoding='UTF-8') as f:
|
with open(path,'w',encoding='UTF-8') as f:
|
||||||
json.dump(user_cookies,f,ensure_ascii=False)
|
json.dump(myb_info,f,ensure_ascii=False)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(path, encoding='utf8') as f:
|
with open(path, encoding='utf8') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user