()
return index_info
初始化索引
初始化索引
初始化索引
def init_index_info():
    '''
    初始化索引
    '''
    index_info = {}
    chapter_dir = os.path.join(blog_path, "chapters")
    os.chdir(chapter_dir)
    for file in os.listdir(chapter_dir):
        name, _ = os.path.splitext(file)
        with open(file, 'r', encoding="utf-8") as f:
            chapter_name = f.readlines()[1].strip()
        index_info[name.replace("p", "")] = {"name": chapter_name, "contents": []}
    return index_info
def init_index_info ( ) : index_info = { } chapter_dir = os . path . join ( blog_path , "chapters" ) os . chdir ( chapter_dir ) for file in os . listdir ( chapter_dir ) : name , _ = os . path . splitext ( file ) with open ( file , 'r' , encoding = "utf-8" ) as f : chapter_name = f . readlines ( ) [ 1 ] . strip ( ) index_info [ name . replace ( "p" , "" ) ] = { "name" : chapter_name , "contents" : [ ] } return index_info