我想从第一个空行开始解析文本文件

bal*_*der 2 python

我想从文本文件的第一个空行开始解析文本文件。每个文本文件的前几行都有我在搜索中不需要的 URL,并且每个文件的标题长度略有不同。每个文件的标题和文本正文之间都有一个空行,因此我想在空行之后开始正则表达式搜索

我知道如何找到空行,但不知道如何获取它们的索引。

myfile = open(mydir,'r')
for line in myfile:
    if line in ['\n', '\r\n']:
        print 'Found it'
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏

Joh*_*ooy 5

with open(mydir,'r') as myfile
    next(line for line in myfile if line.isspace())
    # now myfile is at the first line after the blank line
Run Code Online (Sandbox Code Playgroud)