From 829c8a5322ca699c2bb78e822221ab58c3537709 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 12 Oct 2022 14:37:50 +0800 Subject: [PATCH] :hammer: Replace range(len(...)) with enumerate(...) (#156) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- ck_hostloc.py | 3 +-- ck_nga.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ck_hostloc.py b/ck_hostloc.py index 7a768091..a0f5f551 100644 --- a/ck_hostloc.py +++ b/ck_hostloc.py @@ -159,8 +159,7 @@ def get_points(self, s: req_Session, number_c: int): self.log_current_points(s) # 打印账户当前积分 url_list = self.randomly_gen_uspace_url() # 依次访问用户空间链接获取积分,出现错误时不中断程序继续尝试访问下一个链接 - for i in range(len(url_list)): - url = url_list[i] + for i, url in enumerate(url_list): try: r = s.get(url) r.raise_for_status() diff --git a/ck_nga.py b/ck_nga.py index a023c1f9..e124fea6 100644 --- a/ck_nga.py +++ b/ck_nga.py @@ -158,12 +158,12 @@ def view_video_for_adfree(self, token, uid): failure_msg = "" failure_msg_all = "" code = {} - for i in range(len(ids)): + for i, item in enumerate(ids): try: res = requests.post(self.url, headers=self.headers, data=data).content res = json.loads(res) time.sleep(30) - code[i] = res["data"][1][0][ids[i]]["raw_stat"]["6"] + code[i] = res["data"][1][0][item]["raw_stat"]["6"] if code[i] == 1: success_sum += 1 else: