From b319b67c3ccf4682583b46761f8ba68eb5fac563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E4=B8=9E=E5=AE=8F?= Date: Mon, 2 Jul 2018 17:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E9=99=A4=E9=8C=AF=E8=B3=87?= =?UTF-8?q?=E8=A8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\345\201\232\345\275\261\347\211\207.py" | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git "a/\351\254\245\345\201\232\344\274\231/\345\201\232\345\275\261\347\211\207.py" "b/\351\254\245\345\201\232\344\274\231/\345\201\232\345\275\261\347\211\207.py" index e1fc7ef..69c08b2 100644 --- "a/\351\254\245\345\201\232\344\274\231/\345\201\232\345\275\261\347\211\207.py" +++ "b/\351\254\245\345\201\232\344\274\231/\345\201\232\345\275\261\347\211\207.py" @@ -148,22 +148,20 @@ def 掠聲音(cls, 腔口參數, 漢字, 臺羅): 文章粗胚.數字英文中央全加分字符號(漢字), 文章粗胚.建立物件語句前處理減號(腔口參數['拼音'], 臺羅) ) - conn = http.client.HTTPSConnection( - "xn--lhrz38b.xn--v0qr21b.xn--kpry57d" + domain = "xn--lhrz38b.xn--v0qr21b.xn--kpry57d" + 網址 = "/{}?{}={}&{}={}".format( + quote('語音合成'), + quote('查詢腔口'), + quote(腔口參數['服務腔口']), + quote('查詢語句'), + quote(句物件.看分詞()), ) - conn.request( - "GET", - "/{}?{}={}&{}={}".format( - quote('語音合成'), - quote('查詢腔口'), - quote(腔口參數['服務腔口']), - quote('查詢語句'), - quote(句物件.看分詞()), - ) - ) + conn = http.client.HTTPSConnection(domain) + conn.request("GET", 網址) r1 = conn.getresponse() if r1.status != 200: - print(r1.status, r1.reason) - raise RuntimeError() + raise RuntimeError('連線錯誤:{}{}\n{} {}'.format( + domain, 網址, r1.status, r1.reason + )) return r1.read()