NeteaseMusicLyricDownloader/modules/utils/length.py
2023-04-17 02:41:06 +08:00

8 lines
218 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""一些有关计算长度的工具"""
def len_abs(content):
"""针对中文将一个汉字识别为2个长度而不是1个"""
return len(content) + (len(content.encode("utf-8")) - len(content)) // 2