From d01aa56eb38be29a4d36de9328b0628791b1efca Mon Sep 17 00:00:00 2001 From: Dawnspace <1050596704@qq.com> Date: Sun, 1 Apr 2018 12:55:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bilibiliCilent.py | 3 +-- conf/user.conf | 3 --- configloader.py | 2 +- login.py | 5 +++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/bilibiliCilent.py b/bilibiliCilent.py index 88c3b37..16877b6 100644 --- a/bilibiliCilent.py +++ b/bilibiliCilent.py @@ -304,9 +304,8 @@ async def parseDanMu(self, messages): self.printer.printlist_append(['join_lottery','小电视','user', "# error", response.json()]) if cmd == 'GUARD_MSG': try: - print(dic) a = re.compile(r"(?<=在主播 )\S+(?= 的直播间开通了总督)") - res = a.findall(dic) + res = a.findall(str(dic)) search_url = "https://search.bilibili.com/api/search?search_type=live&keyword=" + str(res[0]) response = requests.get(search_url) roomid = response.json()['result']['live_user'][0]['roomid'] diff --git a/conf/user.conf b/conf/user.conf index 0a15d88..a1bbaf9 100644 --- a/conf/user.conf +++ b/conf/user.conf @@ -14,6 +14,3 @@ danmu = user 普通送礼提示 = True 弹幕 = False - - - diff --git a/configloader.py b/configloader.py index 0099e6d..6f15c69 100644 --- a/configloader.py +++ b/configloader.py @@ -86,7 +86,7 @@ def load_color(self, file): def load_user(self, file): cf_user = configparser.ConfigParser() - # cf_user.read(file) + #cf_user.read(file) cf_user.read_file(codecs.open(file, "r", "utf8")) # print(cf_user._sections['platform']['platform']) dic_user = cf_user._sections diff --git a/login.py b/login.py index 593696b..a3a12d4 100644 --- a/login.py +++ b/login.py @@ -5,6 +5,7 @@ import configparser from urllib import parse import time +import codecs class Login(): @@ -32,10 +33,10 @@ def success(self): username = input("输入用户名:") password = input("输入密码:") config = configparser.ConfigParser() - config.read("conf/user.conf") + config.read_file(codecs.open("conf/user.conf", "r", "utf8")) config.set('account','username',username) config.set('account','password',password) - config.write(open("conf/user.conf", "w+")) + config.write(codecs.open("conf/user.conf", "w+","utf8")) if username != "": value = self.GetHash() key = value['key']