擅长:python、mysql、java
<p>您可以简单地运行以下python脚本:</p>
<pre class="lang-py prettyprint-override"><code>with open("words.txt", "rt") as words:
#create a list with every word
wordList = words.read().split("\n")
with open("subtitle.srt", "rt") as subtitles:
with open("subtitle_output.srt", "wt") as out:
for line in subtitles.readlines():
if line[0].isdigit():
#ignore the line as it starts with a digit
out.write(line)
continue
else:
for word in line.split():
if not word in wordList:
out.write(line.replace(word, f"*{word}*"))
</code></pre>
<p>这个脚本将用修改的<code>*word*</code>替换公共单词文件中不存在的每个单词,保留原始文件并将所有内容放入新的输出文件中</p>