You've already forked lubo_toolkit
节目单找东西工具
This commit is contained in:
25
list_key_finder.py
Normal file
25
list_key_finder.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
search = ["教学", "套路"]
|
||||||
|
|
||||||
|
rf = open("result.txt", "w", encoding="gbk")
|
||||||
|
|
||||||
|
with open("a.txt", "r", encoding="gbk") as f:
|
||||||
|
content = f.read(1 << 20)
|
||||||
|
result = re.findall(r"^(?P<title>[^\t\r\n]+)\t(?P<content>[^\t]+)\t(?P<aid>\d+)\t(?P<bvid>BV[^\t\r\n]+)$", content,
|
||||||
|
re.MULTILINE)
|
||||||
|
for item in result:
|
||||||
|
title, content, aid, bvid = item
|
||||||
|
matched = []
|
||||||
|
for line in content.split("\n"):
|
||||||
|
for key in search:
|
||||||
|
if key in line:
|
||||||
|
matched.append(line)
|
||||||
|
if len(matched) > 0:
|
||||||
|
rf.write("\n".join([
|
||||||
|
title,
|
||||||
|
*matched,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
]))
|
||||||
|
rf.close()
|
Reference in New Issue
Block a user