📜  python 隐藏 vtt 字幕到文本 txt 文件 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:27.194000             🧑  作者: Mango

代码示例1
import re
bad_words = ['-->',''] 


with open('example.en.vtt') as oldfile, open('newfile.txt', 'w') as newfile:
    for line in oldfile:
        if not any(bad_word in line for bad_word in bad_words):
            newfile.write(line)


with open('newfile.txt') as result:
    uniqlines = set(result.readlines())
    with open('sub_out.txt', 'w') as rmdup:
        mylst = map(lambda each: each.strip(">>"), uniqlines)
        print(mylst)
        rmdup.writelines(set(mylst))