fix:指定文件编码,修复windows下的文件读取错误
This commit is contained in:
parent
1e3c69ea90
commit
ae34572d13
@ -136,7 +136,7 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
filename = config.getsettingfile()
|
filename = config.getsettingfile()
|
||||||
with open(filename) as f:
|
with open(filename,encoding="utf-8") as f:
|
||||||
data = json.loads(f.read())
|
data = json.loads(f.read())
|
||||||
config.update_config(data)
|
config.update_config(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -224,7 +224,7 @@ class XiaoMusic:
|
|||||||
self.log.error(f"{self.mi_token_home} file not exist")
|
self.log.error(f"{self.mi_token_home} file not exist")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
with open(self.mi_token_home) as f:
|
with open(self.mi_token_home,encoding="utf-8") as f:
|
||||||
user_data = json.loads(f.read())
|
user_data = json.loads(f.read())
|
||||||
user_id = user_data.get("userId")
|
user_id = user_data.get("userId")
|
||||||
service_token = user_data.get("micoapi")[1]
|
service_token = user_data.get("micoapi")[1]
|
||||||
@ -752,7 +752,7 @@ class XiaoMusic:
|
|||||||
def try_init_setting(self):
|
def try_init_setting(self):
|
||||||
try:
|
try:
|
||||||
filename = self.config.getsettingfile()
|
filename = self.config.getsettingfile()
|
||||||
with open(filename) as f:
|
with open(filename,encoding="utf-8") as f:
|
||||||
data = json.loads(f.read())
|
data = json.loads(f.read())
|
||||||
self.update_config_from_setting(data)
|
self.update_config_from_setting(data)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
Loading…
Reference in New Issue
Block a user