From 3387e547bbd1d9b60ecebaeb542d6bce0bbb314f Mon Sep 17 00:00:00 2001 From: GalaxySnail Date: Thu, 8 Feb 2024 18:17:04 +0800 Subject: [PATCH] =?UTF-8?q?docs/misc/bvid=5Fdesc.md:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=95=B4=E6=95=B0=E9=99=A4=E6=B3=95=E4=BB=A3=E6=9B=BF=E6=B5=AE?= =?UTF-8?q?=E7=82=B9=E6=95=B0=E9=99=A4=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bv号av号转换算法本质上是一种修改过的 base58 运算,参与运算的类型都是 整数类型,所以不应该使用浮点数除法 /= 而应该使用整数除法 //= 这也修复了 mypy 的类型不匹配报错,tmp 变量被推断为整数,而 `tmp /= BASE` 相当于 `tmp = tmp / BASE`,将浮点数赋值给整数,类型不匹配 --- docs/misc/bvid_desc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/misc/bvid_desc.md b/docs/misc/bvid_desc.md index bf14b86..97a6bd0 100644 --- a/docs/misc/bvid_desc.md +++ b/docs/misc/bvid_desc.md @@ -167,8 +167,8 @@ def av2bv(aid: int) -> str: bvid = [""] * 9 tmp = (MAX_AID | aid) ^ XOR_CODE for i in range(CODE_LEN): - bvid[ENCODE_MAP[i]] = ALPHABET[int(tmp % BASE)] - tmp /= BASE + bvid[ENCODE_MAP[i]] = ALPHABET[tmp % BASE] + tmp //= BASE return PREFIX + "".join(bvid) def bv2av(bvid: str) -> int: