From a8c0047bf4a28ee203e97dc053da7747916ad048 Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Thu, 24 Oct 2024 14:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=83=E8=B7=B3=E8=AE=A1?= =?UTF-8?q?=E6=95=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 160f30b..250a3df 100755 --- a/server.py +++ b/server.py @@ -206,7 +206,7 @@ def load_cache(): return None -def update_pairs(addr, ccid, clear=0,cnt=0): +def update_pairs(addr, ccid, clear=0,cnt=[0]): """更新终端库 addr:绑定tcp地址 ccid:终端号 @@ -245,10 +245,11 @@ CCID:{ccid.decode()} clents = ' \n'+'\r\n'.join(od) if len(od) else "" t=f"在线终端已更新,数量{len(od)}。{clents}" logger.info(t) - cnt += 1 - # cnt为1或为10的倍数 - if cnt == 1 or cnt%10 == 0: - cnt = 0 + cnt[0] += 1 + # cnt[0]是一个列表,它的默认值只会在函数定义时初始化一次,因此它的值在多次调用时保持不变 + # cnt[0]为1或为10的倍数 + if cnt[0] == 1 or cnt[0]%10 == 0: + cnt[0] = 0 s2wx("","",t)