From 475f02fbe64edd4ab127445261d64faa0f370acf Mon Sep 17 00:00:00 2001 From: lededev Date: Tue, 12 Apr 2022 06:34:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86format=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E5=86=85=E5=AE=B9=E5=8C=85=E5=90=AB=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8CDEBUG=20INFO?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ADC_function.py | 14 +++++++++++++- core.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index 30a5127..bcda6c9 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -18,6 +18,7 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry from cloudscraper import create_scraper from concurrent.futures import ThreadPoolExecutor +from unicodedata import category def getXpathSingle(htmlcode, xpath): @@ -566,6 +567,7 @@ def delete_all_elements_in_list(string: str, lists: typing.Iterable[str]): new_lists.append(i) return new_lists + def delete_all_elements_in_str(string_delete: str, string: str): """ delete same string in given list @@ -573,4 +575,14 @@ def delete_all_elements_in_str(string_delete: str, string: str): for i in string: if i == string_delete: string = string.replace(i,"") - return string \ No newline at end of file + return string + + +def cnspace(v: str, n: int) -> int: + """ + print format空格填充对齐内容包含中文时的空格计算 + """ + cw = 0 + for c in v: + cw += 1 if category(c) in ('Lo',) else 0 + return n - cw diff --git a/core.py b/core.py index 0300b9e..6767996 100644 --- a/core.py +++ b/core.py @@ -608,7 +608,7 @@ def debug_print(data: json): if i == 'extrafanart': print('[+] -', "%-14s" % i, ':', len(v), 'links') continue - print('[+] -', "%-14s" % i, ':', v) + print(f'[+] - {i:<{cnspace(i,14)}} : {v}') print("[+] ------- DEBUG INFO -------") except: