MCPcopy
hub / github.com/nghuyong/WeiboSpider / reverse_cut_to_length

Function reverse_cut_to_length

weibospider/spiders/common.py:29–42  ·  view source on GitHub ↗

url to mid

(content, code_func, cut_num=4, fill_num=7)

Source from the content-addressed store, hash-verified

27
28
29def reverse_cut_to_length(content, code_func, cut_num=4, fill_num=7):
30 """
31 url to mid
32 """
33 content = str(content)
34 cut_list = [content[i - cut_num if i >= cut_num else 0:i] for i in range(len(content), 0, (-1 * cut_num))]
35 cut_list.reverse()
36 result = []
37 for i, item in enumerate(cut_list):
38 s = str(code_func(item))
39 if i > 0 and len(s) < fill_num:
40 s = (fill_num - len(s)) * '0' + s
41 result.append(s)
42 return ''.join(result)
43
44
45def url_to_mid(url: str):

Callers 1

url_to_midFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected