优化计数格式化函数

This commit is contained in:
shenjack 2024-02-25 02:53:35 +08:00
parent f2624dbcca
commit 9f5956e77a
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -44,7 +44,13 @@ def format_hit_count(count: int) -> str:
if count_len <= 4: if count_len <= 4:
return count_str return count_str
else: else:
return "_".join(count_str[i:i + 4] for i in range(0, count_len, 4)) # 先倒序
# 再插入
# 最后再倒序
count_str = count_str[::-1]
count_str = "_".join([count_str[i:i+4] for i in range(0, count_len, 4)])
count_str = count_str[::-1]
return count_str
def wrap_request(url: str, msg: NewMessage, client: IcaClient) -> Optional[dict]: def wrap_request(url: str, msg: NewMessage, client: IcaClient) -> Optional[dict]: