fix: compatible with python 3.7

This commit is contained in:
lanvent
2023-05-07 23:36:35 +08:00
parent 3e710aa2a1
commit 4f1ed197ce
3 changed files with 9 additions and 5 deletions

View File

@@ -31,7 +31,8 @@ class BaiduTranslator(Translator):
while retry_cnt:
r = requests.post(self.url, params=payload, headers=headers)
result = r.json()
if errcode := result.get("error_code", "52000") != "52000":
errcode = result.get("error_code", "52000")
if errcode != "52000":
if errcode == "52001" or errcode == "52002":
retry_cnt -= 1
continue