mirror of
https://github.com/SocialSisterYi/bilibili-API-collect.git
synced 2024-12-27 21:10:12 +08:00
docs/misc/bvid_desc.md: 使用整数除法代替浮点数除法
bv号av号转换算法本质上是一种修改过的 base58 运算,参与运算的类型都是 整数类型,所以不应该使用浮点数除法 /= 而应该使用整数除法 //= 这也修复了 mypy 的类型不匹配报错,tmp 变量被推断为整数,而 `tmp /= BASE` 相当于 `tmp = tmp / BASE`,将浮点数赋值给整数,类型不匹配
This commit is contained in:
parent
6fd4109cc0
commit
3387e547bb
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user