Python:仅将文本文件中的新条目解析为电报

Python:仅将文本文件中的新条目解析为电报,python,parsing,Python,Parsing,我正在使用Python解析.txt文件,将文本存储为列表,然后将数据写入电报组 我有一个txt解析器 with open ('plog.txt', 'rt') as myfile: contents = myfile.read() myfile = open("plog.txt", "rt") contents = ['myfile.read()'] myfile.close() errors = []

我正在使用Python解析.txt文件,将文本存储为列表,然后将数据写入电报组

我有一个txt解析器

with open ('plog.txt', 'rt') as myfile:
    contents = myfile.read()
myfile = open("plog.txt", "rt")
contents = ['myfile.read()']
myfile.close()

errors = []                       
linenum = 0
substr = "exampletext".upper()          
with open ('plog.txt', 'rt') as myfile:
    for line in myfile:
        linenum += 1
        if line.upper().find(substr) != -1:
            errors.append("Line " + str(linenum) + ": " + line.rstrip('\n'))
for err in errors:
    print(err)
然而,我正在努力识别plog.txt文件的新更新(该文件正在不断更新)。我在想一段简单的代码,看看最后一行倒数第二个条目,但由于在循环过程中可能有多个条目,我认为这没有意义