节目单找东西工具
This commit is contained in:
parent
e34af24e94
commit
cd0a171460
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()
|
Loading…
x
Reference in New Issue
Block a user