class mainprogram():
def getData(self, file, begin, end):
parser = MyHTMLParser()
f = open(file);
rawcontent = f.read()
#Get main content
content = rawcontent.split('<div id="header"')[1];
content = content.split('</html>')[0];
del parsed_data[:]
html = content.split(begin)[1];
html = html.split(end)[0];
parser.feed(html);
result = list(parsed_data);
return result;
我正处于练习Python的阶段,当我在做一个与Python相关的作业时,我被卡住了。上面的代码片段使用htmlparser解析.msg文件,将其转换为csv格式。 有谁能解释一下[1][0]在下面这几行中意味着什么
content = rawcontent.split('<div id="header"')[1];
content = content.split('</html>')[0];
目前我正在使用Python社区版本进行开发,当我突出显示特定的[1]或[0]时,它显示为
class list
def __getitem__(self, y)
如special method names所述,方法名
__getitem__()
允许类重写foo[bar]
语法。列表这样做是为了提供订阅(例如foo[5]
)和切片(foo[1:5]
)。字典这样做是为了提供键查找。你知道吗相关问题 更多 >
编程相关推荐